Here's the sample of mapping, register, and search query.
mapping
curl -X PUT "es:9200/english1" -H 'Content-Type: application/json' -d'
{
"mappings": {
"_doc": {
"properties": {
"header" : {
"type" : "text"
},
"body" : {
"type" : "text"
}
}
}
}
}
'
register
curl -X PUT "es:9200/english1/_doc/1?refresh" -H 'Content-Type: application/json' -d'
{
"header": "something special",
"body": "I am John"
}
'
curl -X PUT "es:9200/english1/_doc/2?refresh" -H 'Content-Type: application/json' -d'
{
"header": "something better",
"body": "You are Chris"
}
'
curl -X PUT "es:9200/english1/_doc/3?refresh" -H 'Content-Type: application/json' -d'
{
"header": "anything hot",
"body": "This is a cup"
}
'
curl -X PUT "es:9200/english1/_doc/4?refresh" -H 'Content-Type: application/json' -d'
{
"header": "anything cold",
"body": "That is a glass"
}
'
search
curl -XGET 'es:9200/english1/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query" : {
"simple_query_string":{
"query": "something",
"fields": ["header","body"]
}
},
"explain": true
}'
result
{
"took" : 5,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 0.6931472,
"hits" : [
{
"_shard" : "[english1][2]",
"_node" : "sN3QHj7oRF-rgbBbs4U6lw",
"_index" : "english1",
"_type" : "_doc",
"_id" : "2",
"_score" : 0.6931472,
"_source" : {
"header" : "something better",
"body" : "You are Chris"
},
"_explanation" : {
"value" : 0.6931472,
"description" : "sum of:",
"details" : [
{
"value" : 0.6931472,
"description" : "weight(header:something in 0) [PerFieldSimilarity], result of:",
"details" : [
{
"value" : 0.6931472,
"description" : "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
"details" : [
{
"value" : 0.6931472,
"description" : "idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:",
"details" : [
{
"value" : 1.0,
"description" : "docFreq",
"details" : [ ]
},
{
"value" : 2.0,
"description" : "docCount",
"details" : [ ]
}
]
},
{
"value" : 1.0,
"description" : "tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from:",
"details" : [
{
"value" : 1.0,
"description" : "termFreq=1.0",
"details" : [ ]
},
{
"value" : 1.2,
"description" : "parameter k1",
"details" : [ ]
},
{
"value" : 0.75,
"description" : "parameter b",
"details" : [ ]
},
{
"value" : 2.0,
"description" : "avgFieldLength",
"details" : [ ]
},
{
"value" : 2.0,
"description" : "fieldLength",
"details" : [ ]
}
...
},
{
"_shard" : "[english1][3]",
"_node" : "sN3QHj7oRF-rgbBbs4U6lw",
"_index" : "english1",
"_type" : "_doc",
"_id" : "1",
"_score" : 0.2876821,
"_source" : {
"header" : "something special",
"body" : "I am John"
},
"_explanation" : {
"value" : 0.2876821,
"description" : "sum of:",
"details" : [
{
"value" : 0.2876821,
"description" : "weight(header:something in 0) [PerFieldSimilarity], result of:",
"details" : [
{
"value" : 0.2876821,
"description" : "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
"details" : [
{
"value" : 0.2876821,
"description" : "idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:",
"details" : [
{
"value" : 1.0,
"description" : "docFreq",
"details" : [ ]
},
{
"value" : 1.0,
"description" : "docCount",
"details" : [ ]
}
]
},
{
"value" : 1.0,
"description" : "tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from:",
"details" : [
{
"value" : 1.0,
"description" : "termFreq=1.0",
"details" : [ ]
},
{
"value" : 1.2,
"description" : "parameter k1",
"details" : [ ]
},
{
"value" : 0.75,
"description" : "parameter b",
"details" : [ ]
},
{
"value" : 2.0,
"description" : "avgFieldLength",
"details" : [ ]
},
{
"value" : 2.0,
"description" : "fieldLength",
"details" : [ ]
}
...
}
According to this Q&A[Understanding doc and docCount values in explain response],
if docCount
the number of docs in my index, I assume docCount
will be 4(but it was wrong in this response.).
Also I cant't understand docFreq
.
Please help me...