Dear ES staff
I am developing a plugin to connect to a local Elasticsearch cluster. I have to programmatically construct ES queries with to Query DSL and have problems with the keyword an text data type. I have done some tests with a small dataset. This is the mapping of the dataset:
{
"test3" : {
"mappings" : {
"_doc" : {
"properties" : {
"key1" : {
"type" : "text"
},
"key2" : {
"type" : "keyword"
},
"key3" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
The question is: for which fields do I have to use the '.keyword' after the field?
In my tests, I noticed that for key3 (default datatype text and keyword) I have to use it for aggregations but cannot use it for filters. All good. So I implemented it this way.
When I try it on a different dataset also having a field with type: text and keyword. I don't get any results back. When I try it with the '.keyword' behind the field, I get the correct results. Could you explain me what the reason is for this different behaviour?