Working on elastic search 6.5.3. I am using function_score to change the weights of the particular results. I am expecting the output as the results with the highest weight comes first and then remaining follows. Below is my Query
When I run the above query the result with the https://www-somesite/sports/second is appearing as first place followed by https://www-somesite/sports/first. Little confusion how I can get https://www-somesite/sports/first in the first place.
The max_boost of 42 is lower than the actual weights of the functions. As a result, both URLs will get the same boost.
Is url a text field or a keyword field? If it is a text field, both URLs will actually match any of your function queries. If so, you may want to change url into url.keyword in your function queries.
How many shards does your index have? With more than one shard, while testing on small datasets, you may get unexpected scoring results. Try creating the www-test-index index with one shard.
Yeah, in your case, if you want to keep the max_boost, you'd need to set it to at least the highest weight (50).
Does it make sense, for the Url to be a text field? Typically, fields like Url are only used for exact searches, not for full-text queries. Often, it makes most sense to map a field like Url as type keyword instead.
As a work-around you could change the match queries in your functions into match_phrase queries.
If you're working with millions of documents then you can forget what I said about shards. I wanted to make sure you were not testing against 2 documents in an index with the default of 5 shards.
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.