I have the following object in the elastic search and I am trying to find any tags.name that contains a substring. I've tried getting all the tags first and then putting in an aggregate and filter, but I don't know what I'm doing wrong because I'm getting all the tags.names, not the ones that contain that substring.
The object.
"hits" : [
{
"tags" : [
{
"datatype" : "STRING",
"values" : [
{
"value_concat" : "DOBTEST22",
"unit" : "",
"value" : "DOBTEST22",
"operator" : "",
"ordernr" : 0
}
],
"name" : "hierarchy"
},
{
"datatype" : "STRING",
"values" : [
{
"value_concat" : "DOBTEST223",
"unit" : "",
"value" : "DOBTEST223",
"operator" : "",
"ordernr" : 0
}
],
"name" : "test24"
}
]
This is the query I tried to build and it doesn't work.
{
"size": 0,
"aggregations": {
"agg": {
"nested": {
"path": "tags"
},
"aggregations": {
"aggregation": {
"terms": {
"field": "tags.name",
"size": 5000,
"min_doc_count": 0,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [
{
"_count": "desc"
},
{
"_key": "asc"
}
]
}
},
"filter": {
"filter": {
"nested": {
"query": {
"bool": {
"must": [
{
"match": {
"tags.name": "*hier*"
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"path": "tags",
"ignore_unmapped": false,
"score_mode": "sum",
"boost": 1
}
}
}
}
}
}
}