last day (15 days later) » 

2:10 PM
Hey @Michael Mincone
 
hello!
this is a very weird issue and i appreciate you helping me out with this
 
```
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 0.22920428,
"hits": [
{
"_shard": "[test][0]",
"_node": "gkxNWkW9QSu4EMorJWgLsQ",
"_index": "test",
"_type": "_doc",
"_id": "1",
"_score": 0.22920428,
"_source": {
"specialties": [
"hand"
]
},
"_explanation": {
"value": 0.22920428,
"description": "weight(specialties:hand in 0) [PerFieldSimilarity], result of:",
"details": [
This is my complete explain API result, can you please share your complete output here
So that it would be easy to debug the issue?
 
```{
"_index" : "test",
"_type" : "_doc",
"_id" : "ZxqWUHUBX_caCRKFLMQx",
"matched" : true,
"explanation" : {
"value" : 0.3955629,
"description" : "weight(specialties:hand in 0) [PerFieldSimilarity], result of:",
"details" : [
{
"value" : 0.3955629,
"description" : "score(freq=1.0), product of:",
"details" : [
{
"value" : 2.2,
"description" : "boost",
"details" : [ ]
},
{
"value" : 0.2876821,
"description" : "idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:",
"details" : [
{
"value" : 1,
thats for "foot", "hand" "eye"
```{
"_index" : "test",
"_type" : "_doc",
"_id" : "ZhqWUHUBX_caCRKFAcQC",
"matched" : true,
"explanation" : {
"value" : 0.2876821,
"description" : "weight(specialties:hand in 0) [PerFieldSimilarity], result of:",
"details" : [
{
"value" : 0.2876821,
"description" : "score(freq=1.0), product of:",
"details" : [
{
"value" : 2.2,
"description" : "boost",
"details" : [ ]
},
{
"value" : 0.2876821,
"description" : "idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:",
"details" : [
{
"value" : 1,
and thats for "hand
 
Thanks @Michael Mincone, let me go through them, and will get back to you in a while :)
 
thank you very much!
 
2:25 PM
The value of "n, number of documents containing term" is 1.0, but it should be 2.0, since both the documents have hand in them. Therefore no. of matching documents should be 2 here. And even values of avgdl is also weird :(
Are these the 2 documents that you have inserted ?

{
"specialties": [
"hand",
"foot",
"eye"
]
}

{
"specialties": [
"hand"
]
}
@Michael Mincone Can you please share your search API result also ? (without explain=true)
 
yes when i do ```GET test/_search/
{
"query": {
"term": {
"specialties": {
"value": "hand",
"boost": 1
}
}
}
}
```
```{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 0.3955629,
"hits" : [
{
"_index" : "test",
"_type" : "_doc",
"_id" : "ZxqWUHUBX_caCRKFLMQx",
"_score" : 0.3955629,
"_source" : {
"specialties" : [
"hand",
"foot",
"eye"
]
}
},
{
"_index" : "test",
"_type" : "_doc",
"_id" : "ZhqWUHUBX_caCRKFAcQC",
"_score" : 0.2876821,
"_source" : {
"specialties" : [
"hand"
]
}
}
]
 
Thank you !! Let me go through them :)
 
2:41 PM
thanks!
 
Have you defined anything in the settings of the index? Like the number of shards or anything related to index setting (while creating the index) ?
 
no
```PUT test/_mapping/
{
"properties": {
"specialties": {
"type": "text",
"norms": false
}
}
}```
this is the only setting i applied to my index
 
3:24 PM
okay
 
does the explain API return similar results for you?
 
No, its actually really weird, I am using elasticsearch version 7.8, and this is my explainAPI result
```
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 0.22920428,
"hits": [
{
"_shard": "[test][0]",
"_node": "gkxNWkW9QSu4EMorJWgLsQ",
"_index": "test",
"_type": "_doc",
"_id": "1",
"_score": 0.22920428,
"_source": {
"specialties": [
"hand"
]
},
"_explanation": {
"value": 0.22920428,
"description": "weight(specialties:hand in 0) [PerFieldSimilarity], result of:",
"details": [
As you can see here avgdl, n value and the total score value are different from yours :|
I am just trying to figure out, what may be the issue, that led you to those weird results
As I used the same mapping, index data and search query
dl value is 1.0 in both the case, that means norms are disabled (but other parameters are giving unexpected values)
 
3:42 PM
0
Q: Elasticsearch-6.x norms false not working

Wu WrestleThat is what I have Done: First: curl -X PUT "localhost:9200/log_20180419" Second curl -X PUT "localhost:9200/log_20180419/_mapping/_doc" -H 'Content-Type: application/json' -d' { "properties": { "title": { "type": "text", "norms": false } ...

i found this and one of the answers was "The norm is only one part of scoring. The norm covers the field length norm and index-time boosting (if you are using that), but term frequency and inverse document frequency (TF/IDF) are independent of it.

If you don't need / want scoring for your query, look into boolean filters or constant score."
 
3:56 PM
Then try out this search query:
{
"query": {
"constant_score": {
"filter": {
"term": { "specialties": "hand" }
}
}
}
}
Constant score query returns every matching document with a relevance score equal to the boost parameter value (which defaults to 1.0)
As it is mentioned, that constant score or filter queries will return only the matched result (score is not considered). But disabling norms means, that now the length of the document is not considered (due to which the IDF score will surely differ)
But if your use case is just to match the result based on the condition (and scoring is not important), then you can go with constant score query or use bool filter
@Michael Mincone if my answer helped you resolve your issue then please don't forget to upvote and accept my answer 🙂
 
thank you. the constant_score does work! i will give you an upvote and accept
 
Thank you 🙂
 

last day (15 days later) »