Illegal_argument_exception

Hi
i'm try to query to Elasticsearch in kibana
But I got some error in there
How can I solve it?

this is my query

POST dingo-dev-images-enriched-index-v1/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "tenant_id": "snoopy"
          }
        },
        {
          "term": {
            "dataset_id": "ds_01G8CKAKZ0ZRVHVDH5RA1R2FEZ"
          }
        }
      ]
    }
  },
  "track_total_hits": true,
  "sort": [
    {
      "id": "desc"
    }
  ],
  "size": 10
}

this is the error

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [id] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
      }
    ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "dingo-dev-images-enriched-index-v1",
        "node" : "f6S8f5v4TXC333O8vPJmPQ",
        "reason" : {
          "type" : "illegal_argument_exception",
          "reason" : "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [id] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
        }
      }
    ],
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [id] in order to load field data by uninverting the inverted index. Note that this can use significant memory.",
      "caused_by" : {
        "type" : "illegal_argument_exception",
        "reason" : "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [id] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
      }
    }
  },
  "status" : 400
}

this is index mapping

{
  "dingo-dev-images-enriched-index-v1" : {
    "mappings" : {
      "properties" : {
        "annotations_search" : {
          "properties" : {
            "class_count" : {
              "properties" : {
                "some-class" : {
                  "type" : "long"
                }
              }
            },
            "count" : {
              "type" : "long"
            },
            "metadata" : {
              "properties" : {
                "train" : {
                  "type" : "text",
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                }
              }
            },
            "type_count" : {
              "properties" : {
                "bbox" : {
                  "type" : "long"
                }
              }
            }
          }
        },
        "attributes" : {
          "properties" : {
            "exif" : {
              "type" : "long"
            },
            "height" : {
              "type" : "long"
            },
            "width" : {
              "type" : "long"
            }
          }
        },
        "class_count" : {
          "properties" : {
            "some-class" : {
              "type" : "long"
            }
          }
        },
        "count" : {
          "type" : "long"
        },
        "created_at" : {
          "type" : "date"
        },
        "created_by" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "dataset_id" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "id" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "key" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "metadata" : {
          "properties" : {
            "car" : {
              "type" : "long"
            },
            "sky" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "train" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            }
          }
        },
        "slices" : {
          "properties" : {
            "id" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "name" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            }
          }
        },
        "source" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "tenant_id" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "type_count" : {
          "properties" : {
            "bbox" : {
              "type" : "long"
            }
          }
        },
        "updated_at" : {
          "type" : "date"
        },
        "updated_by" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    }
  }
}

Hi @Jinhyuck_Cha,
Welcome to our community!

Try replacing the text fields tenant_id and dataset_id with fields of keyword type. In your case it's tenant_id.keyword and dataset_id.keyword.

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