How can I get response(which is searched by score) in Elasticsearch? - elasticsearch

I need your help. I want to a search which can be search by common conditions and its score range also used as conditions。Can I do it successfully? if you know ,I hope you can share.
I have a example in the picture:
In the picture,we know the score range is [0,1] ,if I want to get response which scores is [0.2,0.6],How do it! help! SOS! Execute my English!

Elasticsearch provides a min_score field that can be included in a request body search to filter out documents with a _score less than a specified value.
There is no way to filter out documents with a _score greater than a certain value, but: why do you want to do this? Scores in Lucene by definition mean that documents were found matching your search query, and that some results are more relevant than others. I recommend that you read "What is Relevance?" in the Elasticsearch documentation, and "Apache Lucene - Scoring" for a basic understanding of how the scoring formula works.
Also, the Lucene score range isn't always [0,1]: it can be greater than 1.

Related

Elasticsearch multiple score fields

Maybe a dummy question: is it possible to have multiple score fields?
I use a custom score based on function_score query. This score is being displayed to the user to show, how much each document matches his/her preferences. So far so good.
But! The user should be able to filter the documents and (of course) sort them not only by the custom relevance (how much each document matches his/her preferences) but also by the common relevance - how much each document matches the filter criteria.
So my first idea was to place the score calculated by function_score query to a custom field but it does not seems to be supported.
Or am I completely wrong and I should use another approach?
I took a different approach - in case user applies some filter the I run the query without function_score percolation and use the score calculated by ES and sort by it. Then I take all IDs from the result page and run percolation query with these IDs to get the custom "matching score". It does not seems to cause noticeable slowdown.
Anyway, I welcome any feedback.

What is the purpose of score for a user in elastic search query result?

The main difference between must and filter query is the _score calculation.
Can anyone tell me what is the purpose of the score shown in the query result?
How can we use the score?
The score gives you the relevance of a given document to the executed query. The higher the score, the more relevant is the document. For example, consider the following documents:
# Doc 1
{
"title": "What is the purpose of score for a user in elastic search query result?"
}
# Doc 2
{
"title": "What is the purpose of score in life?"
}
Then, if you query for a title that includes the words purpose score elastic (something you would do, for example, in the stackoverflow search bar), the first document will get a higher score and will appear on top of the list of results.
On the other hand, filters tell you whether a document matches or not the query. It is either a yes or no, therefore, it is not necessary to calculate the score.
For further details, have a read at the always very good Elastic documentation.

Boosting score in Elasticsearch based on aggregation result

I need to boost the score of my documents based on a particular value. That value can be obtained from aggregation query.
Currently I am using 2 queries to do it, would like to achieve it in a single query.
1-So basically first query gets me the highest no of occurrence of a particular chapter based on a simple term/match query.
2- Next step is once I get the highest occurring chapter will fire another query which would basically have the same above query with another term query added with a boost factor of 10.
Any input with this regards is welcomed, if we can accomplish this in one query. Thanks in advance.
Ashit

RethinkDB: custom scoring (like Elasticsearch)

I recently discovered RethinkDB, and find it's query language to be much simpler than Elasticsearch. The only use case I haven't been able to find a solution for is specifying how to score results based on the document's fields, like you can do in Elasticsearch (http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/script-score.html). Is there a way to score the query results in RethinkDB and return only the top-n results?
If you have a query like r.table('comments').filter(r.row('name').eq('tldr')), then you can do something like r.table('comments').filter(r.row('name').eq('tldr')).map({score: CALCULATE_SCORE(r.row), row: r.row}).orderBy('score').limit(n) to return the top n results. Note that his does work proportional to the number of results in the original query. If that's too expensive, you can do something similar with an index by writing r.table('comments').indexCreate('score', CALCULATE_SCORE(r.row)) and then writing r.table('comments').orderBy({index: 'score'}).limit(n).

Using matching document original score in filter script for custom filters score query

I want to use "custom filters score" query and use filters to control the score of resulting documents.
I want a way to use the document's original score as computed by ElasticSearch, and then use that score to calculate the final score of the document, which matches the given filters.
Something like "_docScore * 50/100" as a script for a filter, where "_docScore" is the original score of a document that matches the filter.
How to achieve this in ElasticSearch?
Any help is greatly appreciated.
Regards & Thanks,
Aditya.
Documents in a filtered query would be unranked and have the same score.
http://www.elasticsearch.org/guide/reference/query-dsl/custom-score-query/
But you can use a custom score query together with a filtered query and use a script to calculate a score based on the document values. This was added in 0.90, I believe.

Resources