I have this query and want a span first in SearchField. So that ES shows the string that match closest to the beginning of the field first:
{
"query": {
"bool": {
"should": [
{
"match": {
"FullName": {
"query": "101"
}
}
},
{
"bool": {
"must": [
{
"match": {
"SearchField": {
"minimum_should_match": "100%",
"query": "101"
}
}
},
{
"match": {
"__deleted": {
"query": "false"
}
}
}
]
}
}
]
}
}
}
I tried by adding span_first but it didn't return the same result. Got less hits.
"bool": {
"must": [
{
"span_first": {
"end": 1,
"match": {
"span_term": {
"SearchField": {
"value": "101"
}
}
}
}
},
{
"match": {
"__deleted": {
"query": "false"
}
}
}
]
}
Any idea how to query it?