I’m creating an index via the following:
{"mappings": {"Student": {"properties": {"skills": {"type":"text","analyzer":"english"}}}}}
Then I’m adding three documents to it:
{"index":{"_id":"unr_nedra_north"}}
{"id":"unr_nedra_north","fullName":"Nedra North","skills":"python;java;react;html;front-end development;databases","idAsString":"unr_nedra_north"}
{"index":{"_id":"unr_neha_gurusiddaiah"}}
{"id":"unr_neha_gurusiddaiah","fullName":"Neha Gurusiddaiah","skills":"python;java;react;html;front-end development;databases","idAsString":"unr_neha_gurusiddaiah"}
{"index":{"_id":"wsu_ward_wild"}}
{"id":"wsu_ward_wild","fullName":"Ward Wild","skills":"python;java;react;html;front-end development;databases","idAsString":"wsu_ward_wild"}
As you can see, all three documents have identical “skills” field values. And yet, when I search the index for keyword “java” with this query:
{
"explain": true,
"query": {"match":{"skills" : "java"}}
}
I get different scores for each hit! I can't paste the full results with explanation due to character limits, but the scores are 0.2876821, 0.18232156 and 0.18232156 respectively. Can anyone point me to what I'm doing wrong? I'm NOT using any custom scoring.
How many shards do the index have? Are the two documents with the same score by any chance located in the same shard?
Many thanks for the quick response!
Only one shard—the index has only 12 docs. We’re still in the pre-alpha phase of our product development. I can give you access to the index, if you want to take a look…
--atul
Atul Sudhalkar
Principal Architect
Preparing a minimal recreating script is generally recommended. I ran the following, and had all 3 documents return the same score on Elasticsearch 6.2.2:
PUT test
{
"settings" : {
"number_of_shards" : 1
},
"mappings": {
"Student": {
"properties": {
"skills": {
"type":"text",
"analyzer":"english"
}
}
}
}
}
PUT test/Student/unr_nedra_north
{"id":"unr_nedra_north","fullName":"Nedra North","skills":"python;java;react;html;front-end development;databases","idAsString":"unr_nedra_north"}
PUT test/Student/unr_neha_gurusiddaiah
{"id":"unr_neha_gurusiddaiah","fullName":"Neha Gurusiddaiah","skills":"python;java;react;html;front-end development;databases","idAsString":"unr_neha_gurusiddaiah"}
PUT test/Student/wsu_ward_wild
{"id":"wsu_ward_wild","fullName":"Ward Wild","skills":"python;java;react;html;front-end development;databases","idAsString":"wsu_ward_wild"}
POST test/_refresh
GET test/_search
{
"explain": true,
"query": {"match":{"skills" : "java"}}
}
I forgot to add: thanks a ton for the prompt help!