Below is my complete curl recreation. I expect the _boost values to sort
the documents nicely from 5 to 1. However I get inconsistent results. If i
run this recreation 10 times, I will get a variety of sort orders! Mostly
out of order, sometimes in order etc, but why the inconsistency?
I understand that many factors contribute to the score, not just _boost,
but all these documents are near identical right? How would term frequency
or document length skew the scoring if the docs are the same?
My goal is to index many terms inside the skills field (hence the array) so
I cannot simply move the boost to the document level. I need the boost to
be on a specific term so when I search for that term the scoring should
reflect that specific term's boost value.
What am I doing wrong?
curl -XDELETE 'http://localhost:9200/p'
curl -XPOST 'http://localhost:9200/p'
curl -XPOST 'localhost:9200/p/profile/_mapping' -d '
{
"profile": {
"properties": {
"skills": {
"type": "string",
"omit_term_freq_and_positions" : true,
"index" : "not_analyzed"
}
}
}
}'
curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 5 } ]
}'
curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 4 } ]
}'
curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 1 } ]
}'
curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 3 } ]
}'
curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 2 } ]
}'
curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "python", "_boost": 100 } ]
}'
curl -XPOST "http://localhost:9200/p/_refresh"
curl -XGET 'localhost:9200/p/_search?pretty=true' -d '{
"query": {
"query_string": {
"query": "ruby"
}
},
"sort": [{"_score": "desc"}],
"explain": true
}'
----------------------- OUTPUT -----------------------
{
"took" : 22,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 5,
"max_score" : 2.828427,
"hits" : [ {
"_shard" : 3,
"_node" : "eunz7yXoQvKYGfCbAsltYw",
"_index" : "p",
"_type" : "profile",
"_id" : "2JV5NJYOQoSgUr59XulocA",
"_score" : 2.828427, "_source" : {
"skills": [ { "_value": "ruby", "_boost": 4 } ]
},
"_explanation" : {
"value" : 2.828427,
"description" : "fieldWeight(_all:ruby in 0), product of:",
"details" : [ {
"value" : 2.828427,
"description" : "btq, product of:",
"details" : [ {
"value" : 0.70710677,
"description" : "tf(phraseFreq=0.5)"
}, {
"value" : 4.0,
"description" : "allPayload(...)"
} ]
}, {
"value" : 1.0,
"description" : "idf(_all: ruby=2)"
}, {
"value" : 1.0,
"description" : "fieldNorm(field=_all, doc=0)"
} ]
}
}, {
"_shard" : 4,
"_node" : "eunz7yXoQvKYGfCbAsltYw",
"_index" : "p",
"_type" : "profile",
"_id" : "fuMfbcDcRTqEp3GGSmtUlA",
"_score" : 2.101998, "_source" : {
"skills": [ { "_value": "ruby", "_boost": 5 } ]
},
"_explanation" : {
"value" : 2.1019979,
"description" : "weight(_all:ruby in 0), product of:",
"details" : [ {
"value" : 0.99999994,
"description" : "queryWeight(_all:ruby), product of:",
"details" : [ {
"value" : 0.5945349,
"description" : "idf(_all: ruby=2)"
}, {
"value" : 1.681987,
"description" : "queryNorm"
} ]
}, {
"value" : 2.101998,
"description" : "fieldWeight(_all:ruby in 0), product of:",
"details" : [ {
"value" : 3.535534,
"description" : "btq, product of:",
"details" : [ {
"value" : 0.70710677,
"description" : "tf(phraseFreq=0.5)"
}, {
"value" : 5.0,
"description" : "allPayload(...)"
} ]
}, {
"value" : 0.5945349,
"description" : "idf(_all: ruby=2)"
}, {
"value" : 1.0,
"description" : "fieldNorm(field=_all, doc=0)"
} ]
} ]
}
}, {
"_shard" : 4,
"_node" : "eunz7yXoQvKYGfCbAsltYw",
"_index" : "p",
"_type" : "profile",
"_id" : "GSrNarYwSSm99RPx_XCfSA",
"_score" : 1.2611988, "_source" : {
"skills": [ { "_value": "ruby", "_boost": 3 } ]
},
"_explanation" : {
"value" : 1.2611988,
"description" : "weight(_all:ruby in 1), product of:",
"details" : [ {
"value" : 0.99999994,
"description" : "queryWeight(_all:ruby), product of:",
"details" : [ {
"value" : 0.5945349,
"description" : "idf(_all: ruby=2)"
}, {
"value" : 1.681987,
"description" : "queryNorm"
} ]
}, {
"value" : 1.2611989,
"description" : "fieldWeight(_all:ruby in 1), product of:",
"details" : [ {
"value" : 2.1213202,
"description" : "btq, product of:",
"details" : [ {
"value" : 0.70710677,
"description" : "tf(phraseFreq=0.5)"
}, {
"value" : 3.0,
"description" : "allPayload(...)"
} ]
}, {
"value" : 0.5945349,
"description" : "idf(_all: ruby=2)"
}, {
"value" : 1.0,
"description" : "fieldNorm(field=_all, doc=1)"
} ]
} ]
}
}, {
"_shard" : 3,
"_node" : "eunz7yXoQvKYGfCbAsltYw",
"_index" : "p",
"_type" : "profile",
"_id" : "L5LiRwf7Tr67KAwiz6Rrig",
"_score" : 0.70710677, "_source" : {
"skills": [ { "_value": "ruby", "_boost": 1 } ]
},
"_explanation" : {
"value" : 0.70710677,
"description" : "fieldWeight(_all:ruby in 1), product of:",
"details" : [ {
"value" : 0.70710677,
"description" : "btq, product of:",
"details" : [ {
"value" : 0.70710677,
"description" : "tf(phraseFreq=0.5)"
}, {
"value" : 1.0,
"description" : "allPayload(...)"
} ]
}, {
"value" : 1.0,
"description" : "idf(_all: ruby=2)"
}, {
"value" : 1.0,
"description" : "fieldNorm(field=_all, doc=1)"
} ]
}
}, {
"_shard" : 0,
"_node" : "eunz7yXoQvKYGfCbAsltYw",
"_index" : "p",
"_type" : "profile",
"_id" : "PNx2hHtVShq4ZJbQAEKqaA",
"_score" : 0.4339554, "_source" : {
"skills": [ { "_value": "ruby", "_boost": 2 } ]
},
"_explanation" : {
"value" : 0.4339554,
"description" : "fieldWeight(_all:ruby in 0), product of:",
"details" : [ {
"value" : 1.4142135,
"description" : "btq, product of:",
"details" : [ {
"value" : 0.70710677,
"description" : "tf(phraseFreq=0.5)"
}, {
"value" : 2.0,
"description" : "allPayload(...)"
} ]
}, {
"value" : 0.30685282,
"description" : "idf(_all: ruby=1)"
}, {
"value" : 1.0,
"description" : "fieldNorm(field=_all, doc=0)"
} ]
}
} ]
}
}
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.