Aggregations search results are always lowercase


(Martin_M) #1

Hi,

I have an issue regarding the aggregations search. I've already tried several analyzer and settings in my template/mapping, but the values I get are always in lowercase.

How should a template and a search look like?

Template (only a small part)

{
"index_patterns": "obpd_*",
"settings": {
"index": {
"mapping": {
"ignore_malformed": "true"
},
"analysis": {
"analyzer": {
"autocomplete": {
"type": "custom",
"filter": ["lowercase"],
"tokenizer": "ngram_tokenizer"
},
"test": {
"type": "pattern",
"lowercase": false,
"tokenizer": "ngram_tokenizer"
}
},
"tokenizer": {
"ngram_tokenizer": {
"type": "ngram",
"min_gram": "3",
"max_gram": "3",
"token_chars": ["letter",
"digit"]
}
}
},
"number_of_shards": "1",
"number_of_replicas": "0"
}
},
"mappings": {
"obpd": {
"_routing": {
"required": true
},
"dynamic_templates": [{
"prat_name": {
"mapping": {
"fielddata": true,
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"match": "prat_name"
}
},
{
"hierarchy_names": {
"match": "hierarchy_names",
"mapping": {
"fields": {
"autocomplete": {
"search_analyzer": "standard",
"analyzer": "simple",
"type": "text",
"fielddata": true
},
"raw": {
"type": "keyword",
"search_analyzer": "test",
"analyzer": "test"
}
},
"type": "text",
"fielddata": true,
"search_analyzer": "test",
"analyzer": "test"
}
}
},
{
"hierarchy_ids": {
"mapping": {
"fielddata": true,
"fields": {
...

Document:

{
"_index": "obpd_deu_deu",
"_type": "obpd",
"_id": "3000000000",
"_score": 0.6931472,
"_routing": "3000000000",
"_source": {
"type": "productdata",
"parent_child_relation": "productdata",
"epimId": 3000000000,
"obje_id": 3000000050,
"epob_type_Id": 2020,
"lang_id": 2,
"lang_iso": "deu_DEU",
"clie_id": 1,
"name": "MM_Prod",
...,
...,
"product_change_date_ordernr": "2018-03-13T09:55:13",
"product_change_date_productnr": "2018-03-13T10:15:37",
"product_image_obje_id": null,
"hierarchy_ids": "3000000006:3000000020",
"hierarchy_names": "MMTest:MMTestGrp",
"workflows": [
...
}

Query (from Kibana)

GET obpd_deu_deu/_search
{
"aggs" : {
"MM_Test" : {
"terms" : { "field" : "hierarchy_names.raw" }
}
}
}

or

GET obpd_deu_deu/_search
{
"size": 0,
"aggs": {
"mm_test": {
"terms": {
"field": "hierarchy_names.raw"
},
"aggs": {
"mm_test2": {
"terms": {
"field": "hierarchy_names",
"size": 1
}
}
}
}
}
}

Result

"aggregations": {
"mm_test": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "mmtest:mmtestgrp",
"doc_count": 2,
"mm_test2": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "mmtest:mmtestgrp",
"doc_count": 2
}
]
}
}
]
}
}

As you can see, my document holds this "hierarchy_names": "MMTest:MMTestGrp", and the query returns this "key": "mmtest:mmtestgrp".
And I just can't figure out what is wrong.

Thanks
Martin


(Martin_M) #2

I've found the issue. The analyzer was specified correctly. But in my template was a second mapping for "hierarchy_names" that was specified with the simple analyzer. That mapping was always applied and that's why my changes were not considered at all.

If someone wants to know more, I can explain it in more detail.


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.