Preferring length of value


#1

Hi,
We have the following index:

    {
  "order": 0,
  "index_patterns": ["programs"],
  "settings": {
    "analysis": {
      "filter": {
        "autocomplete_filter": {
          "type": "edge_ngram",
          "min_gram": 2,
          "max_gram": 20
        }
      },
      "analyzer": {
        "autocomplete": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "autocomplete_filter"
          ]
        }
      }
    }
  },
  "mappings": {
    "program": {
      "properties": {
        "title": {
          "type": "text",
          "analyzer": "autocomplete",
          "search_analyzer": "standard"
        }        
      }
    }
  }
}

Problem is that we get the following order:
espnnfl
espnuk
espne60
...
..
...
espn

When we search:
"query": {
"multi_match": {
"query": 'espn',
"fields": [
"title"
],
"fuzziness": "auto"
}
}

How can we get ESPN first? we want to "boost" shorter and equal terms first


(David Pilato) #2

You can combine multiple queries within should clauses in a bool query.
This should work well. You can boost the exact match that way.


#3

Thanks but how do I boost that?


(David Pilato) #4

Using the boost parameter.
Did you check the doc about it?


#5

Got it https://stackoverflow.com/questions/18481600/elasticsearch-boost-importance-of-exact-phrase-match

Thanks!


#6

Actually BOOST isn't supported in match_phrase


(system) #7

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