3

I'm a bit surprised by the behavior that elasticsearch completion has sometimes. I've set up a mapping that has a suggest field. In the input of the suggest field I put 3 elements that are the name, the isin and the issuer of one security.

Here is the mapping that I use :

 "suggest": {
                    "type" : "completion",
                    "analyzer" : "simple"
                } 

When I want to query my index with this query :

{
  "suggest": {
    "my_suggestion": {
      "prefix": "FR0011597335",
      "completion": {
        "field": "suggest"
      }
    }
  }
}

I get a list of results but not necessarilly with my exact prefix and most of the time with the exact match not at the top.

So I'd like to know if there is a way to boost exact matches in a suggestion and make such exact term matches to be in first position when possible.

isherwood
  • 58,414
  • 16
  • 114
  • 157
Christophe
  • 2,131
  • 2
  • 21
  • 35

1 Answers1

0

I think my problem is solved by using a custom analyzer : the simple one was not convenient for the entries I had.

"settings": {
    "analysis": {
        "char_filter": {
            "punctuation": {
                "type": "mapping",
                "mappings": [".=>"]
            }
        },
        "filter": {},
        "analyzer": {
            "analyzer_text": {
                "tokenizer": "standard",
                "char_filter": ["punctuation"],
                "filter": ["lowercase", "asciifolding"]
            }
        }
    }
},

and

            "suggest": {
                "type" : "completion",
                "analyzer" : "analyzer_text"
            } 
Christophe
  • 2,131
  • 2
  • 21
  • 35