0
votes

In Azure Search you can boost a query by using first 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

1
It sounds to me like the title of your question should be "how to boost by filter". Boosting by filter is a common use case. For example when you have a repository with multiple types of files and you want to boost a certain type of files.Dan Gøran Lunde

1 Answers

1
votes

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