Scoring Problem with words of one letter


(Youssef) #1

Hi Everyone ,
i'm a beginner in ElasticSearch, i have an application that use elasticSearch to look for ingredients in a given food or fruit...
i'm facing a problem with scoring if the user for example tape : "Vitamine d"
ElasticSearch will give the "vitamine" phrase that have the best scoring even if the phrase "Vitamine D" exist and normally it should have the highest score.
i see that if the second word "d" in my case is just one letter so elastic search will ignore it.

i did another example : "vitamine b12" and i had the correct score .

here is the query that the application send to the server :

{
"from": 0,
"size": 5,
"query": {
"bool": {
"must": [
{
"match": {
"constNomFr": {
"query": "vitamine d"
}
}
}
],
"should": [
{
"prefix": {
"constNomFr": {
"value": "vitamine d",
"boost": 2
}
}
}
]
}
},
"_source": {
"excludes": [
"alimentDtos"
]
}
}

What i could modify to make it work ?

thank you so much


#2

what's the type of the constNomFr field pls?
if the type is keyword, "vitamine D" won't match the search "vitamine d".
In that case, this field should be analyzed.


(Youssef) #3

in the mapping i found the following lines :
"constNomFr" : {
"type" : "text",
"analyzer" : "french"
},

"constNomFr" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          }

#4

Could you show the result of this query?

GET index/_analyze
{
  "field": "constNomFr",
  "text": "vitamine D"
}

But Have you tried to add the and operator to your match clause? By default the match clause will look for documents with "vitamine" OR "d". So that could be the reason as well.


(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.