Skip to content

Instantly share code, notes, and snippets.

@scuy
Last active December 26, 2015 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scuy/7215710 to your computer and use it in GitHub Desktop.
Save scuy/7215710 to your computer and use it in GitHub Desktop.
How to reproduce zero values for _explanation in elasticsearch.
# create index
curl -XPOST "http://localhost:9200/test"
# create mapping with name field boosted
curl -XPOST "http://localhost:9200/test/user/_mapping" -d '{
"user":{
"properties":{
"name":{
"type":"string",
"boost": 2.0
}
}
}
}'
# insert test data
curl -XPOST "http://localhost:9200/test/user" -d '{
"name": "Test User",
"email": "user@test.org",
"nickname": "test"
}'
# query index with explain option
curl -XGET "http://localhost:9200/test/user/_search?q=test&explain=&pretty=true"
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.26849622,
"hits" : [ {
"_shard" : 2,
"_node" : "XGJXm_GmTqSxLN3A34TL9w",
"_index" : "test",
"_type" : "user",
"_id" : "Jz6fBN1mRROcp-4qnd-0xQ",
"_score" : 0.26849622, "_source" : { "name": "Test User", "email": "user@test.org", "nickname": "test" },
"_explanation" : {
"value" : 0.0,
"description" : "btq, product of:",
"details" : [ {
"value" : 0.0,
"description" : "weight(_all:test in 0) [PerFieldSimilarity], result of:",
"details" : [ {
"value" : 0.0,
"description" : "fieldWeight in 0, product of:",
"details" : [ {
"value" : 0.0,
"description" : "tf(freq=0.0), with freq of:",
"details" : [ {
"value" : 0.0,
"description" : "phraseFreq=0.0"
} ]
}, {
"value" : 0.30685282,
"description" : "idf(docFreq=1, maxDocs=1)"
}, {
"value" : 0.4375,
"description" : "fieldNorm(doc=0)"
} ]
} ]
}, {
"value" : 2.0,
"description" : "allPayload(...)"
} ]
}
} ]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment