# Getting exception while searching search as type field type

**URL:** <https://discuss.elastic.co/t/getting-exception-while-searching-search-as-type-field-type/310839>\
**Category:** Elasticsearch\
**Created:** [July 28, 2022, 8:52am UTC](https://discuss.elastic.co/t/getting-exception-while-searching-search-as-type-field-type/310839 "2022-07-28T08:52:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Munish\_Bhardwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/munish_bhardwaj/32/108963_2.png) [@Munish\_Bhardwaj](https://discuss.elastic.co/u/Munish_Bhardwaj)\
**Post date:** [July 28, 2022, 8:52am UTC](https://discuss.elastic.co/t/getting-exception-while-searching-search-as-type-field-type/310839/1 "2022-07-28T08:52:25Z")

</div>

I have a requirement where I need to implement search recommendations and I have opted for the search as you type field. My existing mapping for the field was "text" and now I have changed it to "search\_as\_you\_type" and reindex the index to get the updated mapping. While querying for the data I am getting below exception.

Mapping:

```auto
"properties": {
      "type": {
        "type": "keyword"
      },
      "title": {
        "type": "search_as_you_type",
        "store": true
      },

```

Request:

```auto
{
	"from": 0,
	"size": 10,
	"timeout": "5000ms",
	"query": {
		"bool": {
			"must": [{
				"bool": {
					"must": [{
						"bool": {
							"should": [ {
								"query_string": {
									"query": "Star",
									"default_field": "title",
									"fields": [],
									"type": "best_fields",
									"default_operator": "or",
									"max_determinized_states": 10000,
									"enable_position_increments": true,
									"fuzziness": "AUTO",
									"fuzzy_prefix_length": 0,
									"fuzzy_max_expansions": 50,
									"phrase_slop": 0,
									"analyze_wildcard": true,
									"escape": false,
									"auto_generate_synonyms_phrase_query": true,
									"fuzzy_transpositions": true,
									"boost": 2.0
								}
							}],
							"adjust_pure_negative": true,
							"minimum_should_match": "1",
							"boost": 1.0
						}
					}],
					"adjust_pure_negative": true,
					"boost": 1.0
				}
			}],
			"adjust_pure_negative": true,
			"boost": 1.0
		}
	}
}

```

Exception:

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Fielddata is not supported on field [title] of type [search_as_you_type]"
      }
    ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "application",
        "node" : "V0bTylUqSXe025iSbyTpKw",
        "reason" : {
          "type" : "illegal_argument_exception",
          "reason" : "Fielddata is not supported on field [title] of type [search_as_you_type]"
        }
      }
    ],
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "Fielddata is not supported on field [title] of type [search_as_you_type]",
      "caused_by" : {
        "type" : "illegal_argument_exception",
        "reason" : "Fielddata is not supported on field [__doc_title] of type [search_as_you_type]"
      }
    }
  },
  "status" : 400
}

```

Please suggest what is wrong here??

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [August 13, 2022, 2:04am UTC](https://discuss.elastic.co/t/getting-exception-while-searching-search-as-type-field-type/310839/2 "2022-08-13T02:04:16Z")

</div>

Hi @Munish_Bhardwaj Welcome to the community!

I thought I had something for you but it was a typo my side

Usually that `fieldata` error is related to trying to do a terms search on a text type but you don't seem to be doing that...

Hmm ... more research needed from my side.. apologies.  
I could not reproduce...

```auto
PUT discuss-my-index-000001
{
  "mappings": {
    "properties": {
      "my_field": {
        "type": "search_as_you_type"
      }
    }
  }
}

PUT discuss-my-index-000001/_doc/1?refresh
{
  "my_field": "quick brown fox jump lazy dog"
}

GET discuss-my-index-000001/_search
{
	"from": 0,
	"size": 10,
	"timeout": "5000ms",
	"query": {
		"bool": {
			"must": [{
				"bool": {
					"must": [{
						"bool": {
							"should": [ {
								"query_string": {
									"query": "Brown",
									"default_field": "my_field",
									"fields": [],
									"type": "best_fields",
									"default_operator": "or",
									"max_determinized_states": 10000,
									"enable_position_increments": true,
									"fuzziness": "AUTO",
									"fuzzy_prefix_length": 0,
									"fuzzy_max_expansions": 50,
									"phrase_slop": 0,
									"analyze_wildcard": true,
									"escape": false,
									"auto_generate_synonyms_phrase_query": true,
									"fuzzy_transpositions": true,
									"boost": 2.0
								}
							}],
							"adjust_pure_negative": true,
							"minimum_should_match": "1",
							"boost": 1.0
						}
					}],
					"adjust_pure_negative": true,
					"boost": 1.0
				}
			}],
			"adjust_pure_negative": true,
			"boost": 1.0
		}
	}
}

```

Results

```auto
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 0.5753642,
    "hits" : [
      {
        "_index" : "discuss-my-index-000001",
        "_id" : "1",
        "_score" : 0.5753642,
        "_source" : {
          "my_field" : "quick brown fox jump lazy dog"
        }
      }
    ]
  }
}

```

---

<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:** [September 10, 2022, 2:04am UTC](https://discuss.elastic.co/t/getting-exception-while-searching-search-as-type-field-type/310839/3 "2022-09-10T02:04:31Z")

</div>

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