- Issue created by @drale01
- π©πͺGermany mkalkbrenner π©πͺ
It is way more readable if you format the scoring:
0.221677 <= weight(tcedgem_X3b_en_body:eros in 0) [SchemaSimilarity], result of: ... 0.221677 <= score(freq=2.0), computed as boost * idf * tf from: ... ... 0.280615 <= idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from: ... ... ... 35.000000 <= n, number of documents containing term ... ... ... 46.000000 <= N, total number of documents with field ... ... 0.789968 <= tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from: ... ... ... 2.000000 <= freq, occurrences of term within document ... ... ... 1.200000 <= k1, term saturation parameter ... ... ... 0.750000 <= b, length normalization parameter ... ... ... 536.000000 <= dl, length of field (approximate) ... ... ... 2081.565200 <= avgdl, average length of field 5.033529 <= weight(tcngramm_X3b_en_title:eros in 0) [SchemaSimilarity], result of: ... 5.033529 <= score(freq=1.0), computed as boost * idf * tf from: ... ... 2.000000 <= boost ... ... 3.444683 <= idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from: ... ... ... 1.000000 <= n, number of documents containing term ... ... ... 46.000000 <= N, total number of documents with field ... ... 0.730623 <= tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from: ... ... ... 1.000000 <= freq, occurrences of term within document ... ... ... 1.200000 <= k1, term saturation parameter ... ... ... 0.750000 <= b, length normalization parameter ... ... ... 3.000000 <= dl, length of field ... ... ... 39.304348 <= avgdl, average length of field
I can't see that you queried any date.
Can you post the the entire query sent to Solr?
use search_api_solr_devel to get it. - π§π¦Bosnia and Herzegovina drale01 Sarajevo
#mkalkbrenner
I edited the json.
I think this is query you need:
https://www.drupal.org/files/issues/2024-05-28/solr_term_eros.txt β - π§π¦Bosnia and Herzegovina drale01 Sarajevo
When I switch from Solr to Database server, Type-specific boosting works. So, perhaps bug is somewhere in Solr.
But Boost more recent dates doesnβt work at all on both Servers.
- π©πͺGermany mkalkbrenner π©πͺ
"fl":"ss_search_api_id,ss_search_api_language,score,hash", "fq":["+index_id:testing_solr_boost", "ss_search_api_language:(\"en\" \"und\")"], "q":"(tcedgem_X3b_en_body:(+\"eros\")^1 tcedgem_X3b_und_body:(+\"eros\")^1 tcngramm_X3b_en_title:(+\"eros\")^2 tcngramm_X3b_und_title:(+\"eros\")^2)",
The created field is neither on the list of fields to be returned nor part of the query or filters.
I agree that there's a difference i the behaviour compared to the database backend, even if the database backend is "cheating".
Boost are not blindly added to each query. Only if the query has something to do with that field.We need to debug this step by step and then decide wether to fix something in the module or not.
1. Try to add filter like
create > 0
in the view.2. Enable retrieve results from Solr on the server edit page.
- π§π¦Bosnia and Herzegovina drale01 Sarajevo
These are results directly from Solr server edit page:
https://www.drupal.org/files/issues/2024-05-29/solr_eros_query.txt β
I tried to add filter
create > 0
on view. But I'm getting the same results on REST json like from Solr server edit page:https://www.drupal.org/files/issues/2024-05-29/view_rest_eros.txt β
I enabled "Retrieve result data from Solr":
But results are same with or without "Retrieve result data from Solr".
I also Inserted "body" field on view now.
- π§π¦Bosnia and Herzegovina drale01 Sarajevo
- π§π¦Bosnia and Herzegovina drale01 Sarajevo
I tried all versions of Search_api_solr and Drupal 10, 9 and 8.8 and I never made Content type and Recent dates to be boosted.
- π§π¦Bosnia and Herzegovina drale01 Sarajevo
I have solution.
I created custom module for boosting content types with event subscriber β :
public function preQuery(PreQueryEvent $event): void { $query = $event->getSearchApiQuery(); $solarium_query = $event->getSolariumQuery(); $boost_queries['product_group_one'] = [ 'query' => 'ss_type:product_group_one^22.0', ]; $boost_queries['product_group_two'] = [ 'query' => 'ss_type:product_group_two^8.0', ]; $boost_queries['product_group_three'] = [ 'query' => 'ss_type:product_group_three^30.0', ]; $boost_queries['product_group_four'] = [ 'query' => 'ss_type:product_group_four^4.0', ]; /** @var \Solarium\Component\EdisMax $edismax */ $edismax = $solarium_query->getEDisMax(); $edismax->addBoostQueries($boost_queries); $solarium_query->addParam('defType', 'edismax'); }
And I also used module Search API Solr Boost by Date β for boosting recent dates.
Both work for me.
- π©πͺGermany mkalkbrenner π©πͺ
$solarium_query->addParam('defType', 'edismax');
Good luck with that one. If it works for you, you could use it. But it has many side effects.
- π©πͺGermany mkalkbrenner π©πͺ
BTW I consider to remove support for this manually set query parser as it causes a lot of issues. Usually edismax has to be set per field in case of multiple values, not for the entire query.
I think I will start by writing warnings to the log.
- π©πͺGermany mkalkbrenner π©πͺ
I verified the code again. The Processor adds a boost factor. But such boost factors only get applied to the query if the first sort criteria is score. It is named Search API Relevance in views.
It works perfectly well.
I checked the debug output in https://www.drupal.org/project/search_api_solr/issues/3450331#comment-15... π¬ Boosting Not Working On Content Type Based and Recent Dates Active gain. It contains no sort parameter and that must be your issue. - π§π¦Bosnia and Herzegovina drale01 Sarajevo
You were right mkalkbrenner.
When I'm using Search API Relevance for sorting I'm getting completely new scores.
Boosting works with content type and recent dates.
Thanks.
- Assigned to mkalkbrenner
- Status changed to Needs work
10 days ago 7:45am 18 June 2024 - π©πͺGermany mkalkbrenner π©πͺ
Thanks for your feedback. We should add a note to the settings form about that.
-
mkalkbrenner β
committed db05bbdd on 4.x
Issue #3450331 by mkalkbrenner: Mention that boosting on Content Type...
-
mkalkbrenner β
committed db05bbdd on 4.x
- Status changed to Fixed
9 days ago 4:11pm 18 June 2024