I am new to Elasticsearch. I have created the below indexes and have pushed the same document to both the indexes. Only the difference is index settings that is first index has five shards and second index has only one shard. I have tried to search the documents in both the indexes and results are in different order.
Index1 –
Five shards and one replica.
Total document 250K. Each document has 40 to 50 fields
Index2
One shards and two replica.
Total document 250K. Each document has 40 to 50 fields
For example, I have tried to match the title field in both the indexes
Yeah. When you have multiple shards and a very small number of documents, the score is biased by the repartition of the documents.
It's better to use one single shard of in the case of testing you can add search_type=dfs_query_then_fetch parameter.
If you want exact match always being on top, you can combine multiple queries within a bool query as should clauses.
HI, Thank you for the clarification. It's really helpful.
One more question. is there any way to give the limit to each should condition in the elasticsearch query. Since my index has more than millions of documents and i have to show results on top for each should condition.
For example, the above query returns the more no of results and top 100 results are based on first condition only (match_phrase) and no results found that match the "Science" keyword.
It would be really helpful if you could share any suggestion to achieve my goal.
Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.
A full reproduction script will help readers to understand, reproduce and if needed fix your problem.
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.