Sort solr result by weighting specific items

I have a solr query that just returns the most recent elements in an index. However, I try, if necessary, if the categories are transferred, have this category field weighted in such a way that if there are matches for the category field, then they are weighted higher, but still have those that are not shown by categories.

therefore, the structure of the document looks something like this:

{id:1, title:"sometitle", category:['cat1','cat2']},{id:1, title:"sometitle", category:[]}

my general query looks something like this:

title:*

but if the categories are passed in i, I would make the same heading: * query, but I would like the results to be sorted so that those results with category fields that correspond to the categories are weighted above

I tried boost query (bq), but it didnโ€™t work (which makes sense because my query should return everything), and I sort the primary score and do the secondary sort in the โ€œcreatedโ€ field

+3
source share
1 answer

If I understand your question correctly, you want certain documents to be rated higher regardless of your request, right? Those documents that have categories in them should be better than without categories?

If this is what you want, see below: How to increase the rating for certain documents? .

Alternatively, you can ask to speed up the process only if you request them. Your request must be

+(title:"title to search for") category:"categories to boost"

, , , , .

+3

Source: https://habr.com/ru/post/1767556/


All Articles