Changing default analyzers in a Filter Bucket, one for Query-Terms and a different one for Aggregation-Terms


(Marco Guillen) #1

I have a ElasticSearch index that is dynamically created beginning with a pivot table so having a document with n/dynamic properties and I am trying to set a default analyzer for a query-terms and another for the aggregated documents in the result buckets in ElasticSearch 2.0.0. The default analyzer that I would like to apply to the query is based on ["lowercase","asciifolding"] but I need aggretation results without any analyzer(no lowercase and with accents). How can I achieve this?

The default analyzer I would like to associate to query is (but it is affecting the aggregation bucket too):
"index":{
"analysis": {
"analyzer":{
default": {
"type": "custom",
"filter": ["lowercase"],
"tokenizer": "keyword"
}
}
}
}

My search is this:

{
"query": {
"bool": {
"filter": [
{
"term": {
"type": "autos"
}
},
{
"terms": {
"type_autos_brand": [
"acura"
]
}
}
]
}
},
"aggs": {
"types": {
"terms": {
"field": "type_autos_province",
"size": 1000
}
}
},
"size": 0
}

An example of the result bucket (estado de mexico will be Estado de México):

{
"took": 3,
"hits": {
"total": 281,
"max_score": 0,
"hits": []
},
"aggregations": {
"types": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "estado de méxico",
"doc_count": 64
},
{
"key": "distrito federal",
"doc_count": 53
},


(system) #2