Boosting docs based on date range - azure-cognitive-search

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."
}
}

Please take a look at scoring profiles in Azure Search. https://learn.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

Related

Solr facet column with a condition

I have following facet query which is working fine. However as you can see I need from_usa as one more parameter, I have a country column and it needs to be conditional. Would that be possible ? I cant not use fq filters in this case.
{
"facet":{
"total_game_plays" : "count",
"unique_game_players" : "unique(uuid)",
"total_play_time":"sum(play_time)",
//"from_usa": "unique(where country=US)"
}
}
I assume you're using the JSON facet API from the syntax you've provioded, so a JSON facet query should do what you want:
"from_usa": {
"type": "query",
"q": "country:US"
}

Group by and Count(*) in Datastax Search/Solr

Hi we have a solr index with diff fields in it like business,businessType, regionName, StateName, .....
Now I need a solr query to get the number of business of type businessType ='event' group by regionName.
if I want to write a sql query for this it would be select region_name , Count(business) from solr where businessType='event' group by region_name
Any pointer would be helpful
I finally figured out how to do this. Note, if you need to query on a field with a space or a special character, you need to put the search term in quotes, e.g. businessType:"(fun) event".
curl http://localhost:8983/solr/yourCollection/query -d
{ "query"="*:*",
"fq"="businessType:event",
"rows"=0,
"json.facet"= { "category" : {
"type": "terms",
"field" : "region_name",
"limit" : -1 }}
}
One more Note: if you want to count over 2 fields, you have to do a nested facet.
curl http://localhost:8983/solr/yourCollection/query -d
{ "query"="*:*",
"fq"="businessType:event",
"rows"=0,
"json.facet"= { "category1" : {
"type": "terms",
"field" : "regionName",
"limit" : -1,
"facet" : { "category2" : {
"type": "terms",
"field" : "stateName",
"limit" : -1
}}}}
}
Add another facet chunk after the "limit":-1 item if you need to group by a third dimension. I tried this on my company's Solr and it hung, never returning anything but a timeout error. In general, working with Solr isn't very easy... and the documentation, IMO, is pretty terrible. And absolutely nothing about the syntax or names of the commands seem intuitive at all...
Use facets. Your solr query will look like, q=:&fq=businessType:event&facet=true&facet.field=region_name&rows=0
if want to group by on multiple fields then we need to do facet.pivot=state,region_name

Include fields other than count in azure facet results?

While faceting azure search returns the count for each facet field by default.How do I also get other searchable fields for every facet?
Ex When I facet for area , I want something like this.(description is a searchable field)
{
"area": [
{
"count": 1,
"description": "Acrylics",
"value": "ACR"
},
{
"count": 1,
"description": "Power",
"value": "POW"
}
]
}
Can someone please help with the extra parameters I need to send in the query?
Unfortunately there is no good way to do this as there is no direct support for nested faceting in Azure search (you can upvote it here). To achieve the result you want you would need to store the data together as a composite value as described by this workaround.

How to search one certain field’s value with not unique results on elasticsearch

Need some advise.
I have indexed documents in elasticsearch, now i want to search all results with one certain field value with all related document, like following if i search for reportId=12345, the results will have several documents related, how can i use one api to get results with not unique on certain field
POST myindex/type/_search
{
"query": {
"match": {
"reportId": "12345"
}
}
}

Solr contextual query boosting

I am new to Solr and I would like to boost my results with a contextual parameter.
For example, in a simple case, admit my documents are :
{
"id": "1",
"list":[]
}
{
"id": "2",
"list": ["3"]
}
...
If I have a query like for example :
http://localhost:8983/solr/MyCore/select?q=*:*&contextParam=3
I would like to boost all documents which list contains the contextParam.
I already use the edismax parser to boost documents on other fields like dates but right now I can't access this optional parameter.
Thank you !

Resources