Reputation: 63
I made the field on which aggregation is to be done as "not_analyzed". But now the search is not working on the field. How can I make aggregation working in the field and also searchable?
Upvotes: 2
Views: 60
Reputation: 217564
You simply need to map your field as a string multi field with an analyzed part (for search) and a non analyzed part (for aggregations). Basically like this:
{
"my_field": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
Your query would then search on the my_field
field, and aggregate on the my_field.raw
sub-field.
Upvotes: 2