user20071254
user20071254

Reputation: 1

Nested path "variants" is not nested

I am encountering an issue with Elasticsearch nested type mapping. Below is the configuration for my variants field in the index mapping:

"default_mapping": {
  "properties": {
    "variants": {
      "type": "nested",
      "properties": {
        "admin_graphql_api_id": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
      ...
      }
    }
  }
}

And here is my query:

{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "product",
            "fields": [
              "document_type"
            ],
            "default_operator": "AND"
          }
        }
      ],
      "must_not": [
        {
          "match": {
            "tags.keyword": "hide_me"
          }
        }
      ]
    }
  },
  "aggs": {
    "6f74": {
      "nested": {
        "path": "variants"
      },
      "aggs": {
        "price_range": {
          "filter": {
            "bool": {
              "must_not": [
                {
                  "match": {
                    "tags.keyword": "hide_me"
                  }
                }
              ],
              "filter": {
                "range": {
                  "variants.original_price": {
                    "gt": -9999
                  }
                }
              }
            }
          },
          "aggs": {
            "min_price": {
              "min": {
                "field": "variants.price"
              }
            },
            "max_price": {
              "max": {
                "field": "variants.price"
              }
            }
          }
        }
      }
    }
  }
}

But I am receiving the following error:

"body": {
    "error": {
        "root_cause": [
            {
                "type": "aggregation_execution_exception",
                "reason": "[nested] nested path [variants] is not nested"
            }
        ],
        "type": "search_phase_execution_exception",
        "reason": "all shards failed",
        "phase": "query",
        "grouped": true,
        "failed_shards": [
            {
                "shard": 0,
                "index": "xyz",
                "node": "abc",
                "reason": {
                    "type": "aggregation_execution_exception",
                    "reason": "[nested] nested path [variants] is not nested"
                }
            }
        ]
    },
    "status": 500
},

It seems the variants field isn't being recognized as a nested field. Could someone help me understand why I'm getting this error and how to fix it? I am using [email protected]

Upvotes: 0

Views: 14

Answers (0)

Related Questions