Use boost to pick the first match on top.
Using two wildcard query
curl -XPOST "http://hostname:9200/index/type/_search" -d'
{
"size": 2000,
"query": {
"bool": {
"should": [
{
"wildcard": {
"name": {
"value": "*le*"
}
}
},
{
"wildcard": {
"name": {
"value": "le*",
"boost": 5
}
}
}
]
}
}
}'
Using one wildcard and one prefixquery
curl -XPOST "http://hostname:9200/index/type/_search" -d'
{
"size": 2000,
"query": {
"bool": {
"should": [
{
"wildcard": {
"name": {
"value": "*le*"
}
}
},
{
"prefix": {
"name": {
"value": "le",
"boost": 2
}
}
}
]
}
}
}'