Elasticsearch exeact match on analyzed field of integers

636 views Asked by At

I want to find exact matches on a (analyzed string) field in ES. All values are integers but mapped as strings. I, unfortunately, cannot change the mapping and using

query: {
  match: {
    fieldName: '1234'
  }
}

also gives me 0 hits. I cannot figure out if it's the standard analyzer working in a bizarre way when the mapping is

index: {
 type: {
  properties: {
   fieldName: {
    type: string
   }
  }
 }
}

and data is

{fieldName: '12345'} 

or there is something in the match query that I'm missing.

Thanks :)

1

There are 1 answers

0
soote On

Change your quotations for the fieldNames value from ticks ' to quotes ". Trying your query will the correct quotes returns the expected results on my end.

{
    "query": {
        "match": {
            "fieldName": "1234"
        }
    }
}