1

I'm trying to build a nested aggregation in elasticsearch but it keeps giving errors. It says "cannot find agg type tags". How can I fix it. Thank you for your helps.Btw I don't have nested documents I have one document having 180 fields. Can I apply this aggregation? Here is my code:

{
  "aggs": {
     "comments": { 
      "nested": {
        "path": "comments"
      },
     "aggs" : {
    "red_products": {
      "filter": {
        "not": {
          "terms": {
            "text": [
              "06melihgokcek",
              "t.co","??","????","???"
            ]
          }
        }
      },
      "aggs": {
        "top_docs": {
          "terms": {
            "field": "text",
            "size": 50
          }
        },

      "aggs" : {
            "tags" : {
            "terms" : {
                "field" : "text",
                "include" : ".*avni.*",
                "exclude" : "fuat_.*"
            }
        }
    }
      }


    }
  }
}}}

1 Answer 1

1

Your innermost aggs (the one called tags at the bottom) is misplaced and should be a child element of top_docs.

{
  "aggs": {
    "comments": {
      "nested": {
        "path": "comments"
      },
      "aggs": {
        "red_products": {
          "filter": {
            "not": {
              "terms": {
                "text": [
                  "06melihgokcek",
                  "t.co",
                  "??",
                  "????",
                  "???"
                ]
              }
            }
          },
          "aggs": {
            "top_docs": {
              "terms": {
                "field": "text",
                "size": 50
              },
              "aggs": {                   <---- this was the misplaced aggs
                "tags": {
                  "terms": {
                    "field": "text",
                    "include": ".*avni.*",
                    "exclude": "fuat_.*"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.