I am attempting to query the .raw version of a field that I have in my elasticsearch (version 5.0.0) index. The name of the field is 'region' and its mapping is the following:
{
"properties": {
"region": {
"type": "text", "analyzer": "custom_analyzer",
"fields": {
"raw": {
"type": "keyword", "index": "not_analyzed"
}
}
}
}
}
Note that I had initially set the region mapping with the analyzed version and in the second step I updated the mapping by adding the raw version of the field.
As far as I understood from the documentation and a similar question here, I can query the raw field to get the documents whose regions exactly match my query. However, by using the following query, no results are returned.
{
"match": {
"region.raw": "Northern Ireland"
}
}
In contrary, by using the analyzed version of my field, the results are returned as expected.
{
"match": {
"region": "Northern Ireland"
}
}
As I need to use the raw field, I have the following questions:
Thank you very much for your help.
Nope, you query is correct. The problem is that you have to reindex your data in order to index with the new mapping version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With