简体   繁体   中英

Azure Cognitive Search: How to boost a filter

In Azure Search you can boost a query by using first term || secondterm^2first term || secondterm^2 to give more weight to a particular part of the query.

You can also filter for documents that belong to a particular group using search.in() : https://docs.microsoft.com/en-us/azure/search/search-query-odata-search-in-function

$filter=group_ids/any(g: search.in(g, '123, 456, 789'))

What I would like to do is boost a document if it belongs to a group but not restrict to only documents that belong to that group.

Something like:

search=mysearchterm^3&$filter=group_ids/any(g: search.in(g, '123, 456, 789'))^2

But (1) boosting on the filter doesn't seem to work and (2) this would restrict to only documents that belong to group 123,456,789. I would like it to only boost if it belongs, but not restrict to only those groups.

Is this possible?

I've had a look at "Tag Boosting": https://azure.microsoft.com/en-au/blog/personalizing-search-results-announcing-tag-boosting-in-azure-search/

But it doesn't seem relevant, it only seems possible to tag boost a top level string field, not a string or int field within a collection.

UPDATE:

I think i've figured it out as:

search=mysearchterm AND (group_id:123)^2

If you're using a complex collection it might be:

search=mysearchterm AND (groups/id:123)^2

Filters are designed to constrain your result set by filtering out documents that don't match the filter criteria. This process happens before term matching and scoring. Given that this is not what you are trying to do, I don't think filters are the right tools for the job.

You can try to instead craft a Lucene query that includes the logic you described:

mysearchterm OR (mysearchterm AND group_ids:(123 OR 456 OR 789))^2 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM