# Illegal\_argument\_exception

**URL:** <https://discuss.elastic.co/t/illegal-argument-exception/320962>\
**Category:** Kibana\
**Created:** [December 11, 2022, 3:04am UTC](https://discuss.elastic.co/t/illegal-argument-exception/320962 "2022-12-11T03:04:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jinhyuck\_Cha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jinhyuck_cha/32/114522_2.png) [@Jinhyuck\_Cha](https://discuss.elastic.co/u/Jinhyuck_Cha)\
**Post date:** [December 11, 2022, 3:04am UTC](https://discuss.elastic.co/t/illegal-argument-exception/320962/1 "2022-12-11T03:04:39Z")

</div>

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

```auto
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

```auto
{
  "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

```auto
{
  "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
            }
          }
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![jughosta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jughosta/32/107160_2.png) [@jughosta](https://discuss.elastic.co/u/jughosta)\
**Post date:** [December 11, 2022, 4:38pm UTC](https://discuss.elastic.co/t/illegal-argument-exception/320962/2 "2022-12-11T16:38:55Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 8, 2023, 12:39pm UTC](https://discuss.elastic.co/t/illegal-argument-exception/320962/3 "2023-01-08T12:39:39Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 5, 2023, 12:40pm UTC](https://discuss.elastic.co/t/illegal-argument-exception/320962/4 "2023-02-05T12:40:40Z")

</div>

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