Hi guys, I find myself making some changes to an old scrits and I have the doubt that it would be more optimal if I continue using ' fielddata ' or ' nested ' that is to say the scripts do the searches or aggregations from a field like this: "categoryId ":" L: 1001 L: 1016 L: 1023 L: 1029 L: 1036 "
so what I want is to establish a ' nested ' to search by ID within it. according to reading 'fielddata' consumes a lot of memory but nested consumes more or is it more optimal at the time of truth?
Example FieldData :
POST listing/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"status": true
}
}
]
}
},
"post_filter": {
"bool": {
"filter": [
{
"terms": {
"categoryId": [
1
]
}
}
]
}
},
"aggs": {
"category": {
"terms": {
"field": "categoryId"
}
}
},
"size": 1
}
Example Nested:
POST listing/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"status": true
}
}
]
}
},
"post_filter": {
"bool": {
"must": [
{
"nested": {
"path": "categoryData",
"query": {
"bool": {
"must": [
{
"terms": {
"categoryData.id": [
1
]
}
}
]
}
}
}
}
]
}
},
"aggs": {
"aggsCategory": {
"nested": {
"path": "categoryData"
},
"aggs": {
"category": {
"terms": {
"field": "categoryData.id",
"size": 100
}
}
}
}
},
"size": 10
}