I need to tune search relevance for ads. In the project we are not deleting ads in time.
But we need to show up more-or-less fresh ads for users. So I decided to use the function_score query.
But it does not works - relevance is changing, but actually I'm getting the same result every time.
I tried to choose different values for the function, but did not notice the difference.
The ad_type field on which you are doing a term query is analyzed using the russian analyzer. You probably want to make it a not_analyzed field if you are using it for term queries?
You have put the range query on the created_at field and the term query on the ad_type field inside of the must clause of your bool query. Things that you put inside of a must clause will contribute to the score that's calculated for your documents when you query them. In the case of these range and term queries, the score will be 1 if a document matches or 0 if it doesn't match. However, it probably doesn't make sense that you score on these clauses? Either a document is in this range and matches the ad_type or it doesn't. These two clauses should not contribute to the score. So, I'd recommend that you put them in a filter clause instead.
My first step would be to clean up the query along the points that I raised above. It will give you a better score, and a score that's easier to understand. If you still have problems after doing so, let me know and I'd be happy to delve deeper.
By the way, do you know about the explain API? It will explain in great detail how a score is calculated.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.