I doing a query to search for multiple indices on Elasticsearch. The problem here is the priority of the result doesn't follow what I think.
For example, I have 2 indices: index_1 and index_2
In Index_1 have ~80 docs, contain:
- Doc_1_A: contain 2 keyword "test search"
- Doc_1_B: contain 1 keyword "test search"
In Index_2 have ~10 docs, contain:
- Doc_2_A: contain 2 keyword "test search"
my request:
***/index_1,index_2/_search)
my query:
{
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": [
"Name",
"Desc"
],
"query": "test search",
"analyzer": "whitespace",
"fuzziness": "AUTO",
"default_operator": "AND"
}
}
]
}
},
"size": 20,
"highlight": {
"require_field_match": true,
"fields": {
"*": {
"fragment_size": 100,
"number_of_fragments": 1
}
}
}
}
The result I got after the request search show the priority like this:
Doc_1_A >> Doc_1_B >> Doc_2_A
What I expect is: (since Doc_2_A has more match keyword than Doc_1_B)
Doc_1_A >> Doc_2_A >> Doc_1_B
I do read about the score of ES, it got affected by the TF and IDF (the result got mess up cause the number of docs in Index_1 is much more larger than the Index_2). The score of Doc_2_A is much more smaller than Doc_1_B, this is why the priority doesn't look like what I expect.
When I reindex my two indices into one ( index_merged ), and then search on that mutual index, the result would be like what I expect. But with this new index, I can't update this when there is a new doc or a doc got removed.
But if I search on multi index like my query, I can't get what I expect.
So there is any way to help me with this?