I can reproduce this situation with below script.
maybe the problem could be n
is bigger than N
@dadoonet
curl -X DELETE "localhost:9700/some_index"
curl -X PUT "localhost:9700/some_index" -H 'Content-Type: application/json' -d'
{
"settings": {
"number_of_shards": 5,
"number_of_replicas": 1
},
"mappings": {
"dynamic": false,
"properties": {
"user_id": {
"type": "integer"
},
"introduction": {
"type": "text"
},
"occupation_name": {
"type": "text",
"fields": {
"standard": { "type": "text" },
"raw": { "type": "keyword" }
}
}
}
}
}
'
curl -X PUT "localhost:9700/some_index/_doc/1" -H "Content-Type: application/json" -d'
{
"user_id": 1,
"introduction": "ruby web developer"
}
'
curl -X PUT "localhost:9700/some_index/_doc/2" -H "Content-Type: application/json" -d'
{
"user_id": 2,
"introduction": "ruby developer",
"occupation_name": "ruby developer"
}
'
curl -X PUT "localhost:9700/some_index/_doc/3" -H "Content-Type: application/json" -d'
{
"user_id": 3,
"introduction": "ruby and rails develop"
}
'
curl -X PUT "localhost:9700/some_index/_doc/4" -H "Content-Type: application/json" -d'
{
"user_id": 4,
"introduction": "I develop with ruby on rails"
}
'
curl -X PUT "localhost:9700/some_index/_doc/5" -H "Content-Type: application/json" -d'
{
"user_id": 5,
"introduction": "I develop with ruby on rails"
}
'
curl -X PUT "localhost:9700/some_index/_doc/6" -H "Content-Type: application/json" -d'
{
"user_id": 6,
"introduction": "I develop with ruby on rails"
}
'
curl -X PUT "localhost:9700/some_index/_doc/7" -H "Content-Type: application/json" -d'
{
"user_id": 7,
"introduction": "I develop with ruby on rails"
}
'
curl -X PUT "localhost:9700/some_index/_doc/8" -H "Content-Type: application/json" -d'
{
"user_id": 8,
"introduction": "I develop with ruby on rails"
}
'
curl -X PUT "localhost:9700/some_index/_doc/9" -H "Content-Type: application/json" -d'
{
"user_id": 9,
"introduction": "I develop with ruby on rails"
}
'
curl -X PUT "localhost:9700/some_index/_doc/10" -H "Content-Type: application/json" -d'
{
"user_id": 10,
"introduction": "I develop with ruby on rails"
}
'
curl -X PUT "localhost:9700/some_index/_doc/11" -H "Content-Type: application/json" -d'
{
"user_id": 11,
"introduction": "I develop with ruby on rails"
}
'
and query
curl -X GET "localhost:9700/some_index/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "ruby",
"type": "cross_fields",
"fields": [
"occupation_name^5",
"introduction^2"
],
"slop": 10
}
}
]
}
},
"functions": []
}
},
"from": 0,
"size": 10,
"explain": true
}
'
the response:
...
"_source": {
"user_id": 2,
"introduction": "ruby developer",
"occupation_name": "ruby developer"
},
"_explanation": {
"value": 0.45840853,
"description": "max of:",
"details": [
{
"value": -1.1157178,
"description": "weight(occupation_name:ruby in 0) [PerFieldSimilarity], result of:",
"details": [
{
"value": -1.1157178,
"description": "score(freq=1.0), product of:",
"details": [
{
"value": 11,
"description": "boost",
"details": []
},
{
"value": -0.22314355,
"description": "idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:",
"details": [
{
"value": 2,
"description": "n, number of documents containing term",
"details": []
},
{
"value": 1,
"description": "N, total number of documents with field",
"details": []
}
]
},
...