Boosting docs based on date range

2019-08-23 07:36发布

问题:

I am to be able to filter documents based on a date, but what I really need is to boost certain date ranges higher. The following query returns results.

{
  "queryType":"full",
  "search": "(priority:High^50 || Normal^10) AND (type:one^1 || two^10)",
  "filter": "(type eq 'one' or type eq 'two') and publishedDate eq 2018-04-01", 
  "searchMode": "all"
}

But I don't really want to filter those, I want to boost certain dates. What I really want is something like this:

{
  "queryType":"full",
  "search": "(priority:High^50 || Normal^10) AND (type:one^1 || two^10) AND publishedDate:2018-04-01^100",
  "filter": "(type eq 'one' or type eq 'two')", 
  "searchMode": "all"
}

I get an error: { "error": {"code": "", "message": "Illegal arguments in query request: publishedDate is not a searchable field." } }

回答1:

Please take a look at scoring profiles in Azure Search. https://docs.microsoft.com/en-us/rest/api/searchservice/add-scoring-profiles-to-a-search-index. You can specify a freshness function on the datetime field and give a range of dates to boost matches.

Nate