# Error when querying on search\_as\_you\_type subfields (.\_2gram, .\_3gram)

**URL:** <https://discuss.elastic.co/t/error-when-querying-on-search-as-you-type-subfields-2gram-3gram/268751>\
**Category:** Elasticsearch\
**Created:** [March 30, 2021, 8:56am UTC](https://discuss.elastic.co/t/error-when-querying-on-search-as-you-type-subfields-2gram-3gram/268751 "2021-03-30T08:56:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mariskaas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@mariskaas](https://discuss.elastic.co/u/mariskaas)\
**Post date:** [March 30, 2021, 8:56am UTC](https://discuss.elastic.co/t/error-when-querying-on-search-as-you-type-subfields-2gram-3gram/268751/1 "2021-03-30T08:56:42Z")

</div>

Hi there. I've been trying to use search\_as\_you\_type for an autocomplete solution. I've mapped a field as the "search\_as\_you\_type" type, however when trying to query on the field, the .\_2gram and .\_3gram field, as described in the documentation ([Search-as-you-type field type | Elasticsearch Reference [7.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.12/search-as-you-type.html)) I get an error:

```auto
    {
      "error" : {
        "root_cause" : [
          {
            "type" : "query_shard_exception",
            "reason" : "failed to create query: class org.elasticsearch.index.mapper.SearchAsYouTypeFieldMapper$SearchAsYouTypeAnalyzer cannot be cast to class org.elasticsearch.index.analysis.ReloadableCustomAnalyzer (org.elasticsearch.index.mapper.SearchAsYouTypeFieldMapper$SearchAsYouTypeAnalyzer is in unnamed module of loader java.net.FactoryURLClassLoader @60f21960; org.elasticsearch.index.analysis.ReloadableCustomAnalyzer is in unnamed module of loader 'app')",
            "index_uuid" : "-B_u7gl-Qqaxumkt5v7D9Q",
            "index" : "werkzaamheden_v3"
          }
        ],
        "type" : "search_phase_execution_exception",
        "reason" : "all shards failed",
        "phase" : "query",
        "grouped" : true,
        "failed_shards" : [
          {
            "shard" : 0,
            "index" : "werkzaamheden_v3",
            "node" : "FLpy4hJrRkWsc0lco0QteA",
            "reason" : {
              "type" : "query_shard_exception",
              "reason" : "failed to create query: class org.elasticsearch.index.mapper.SearchAsYouTypeFieldMapper$SearchAsYouTypeAnalyzer cannot be cast to class org.elasticsearch.index.analysis.ReloadableCustomAnalyzer (org.elasticsearch.index.mapper.SearchAsYouTypeFieldMapper$SearchAsYouTypeAnalyzer is in unnamed module of loader java.net.FactoryURLClassLoader @60f21960; org.elasticsearch.index.analysis.ReloadableCustomAnalyzer is in unnamed module of loader 'app')",
              "index_uuid" : "-B_u7gl-Qqaxumkt5v7D9Q",
              "index" : "werkzaamheden_v3",
              "caused_by" : {
                "type" : "class_cast_exception",
                "reason" : "class org.elasticsearch.index.mapper.SearchAsYouTypeFieldMapper$SearchAsYouTypeAnalyzer cannot be cast to class org.elasticsearch.index.analysis.ReloadableCustomAnalyzer (org.elasticsearch.index.mapper.SearchAsYouTypeFieldMapper$SearchAsYouTypeAnalyzer is in unnamed module of loader java.net.FactoryURLClassLoader @60f21960; org.elasticsearch.index.analysis.ReloadableCustomAnalyzer is in unnamed module of loader 'app')"
              }
            }
          }
        ]
      },
      "status" : 400
    }

```

**This is the query:**

```auto
    GET werkzaamheden_v3/_search
    {
      "query": {
        "multi_match": {
          "query": "wass",
          "type": "bool_prefix",
          "fields": [
            "omschrijving",
            "omschrijving._2gram",
            "omschrijving._3gram"
          ]
        }
      }
    }

```

**This is the part of the mapping that contains that field and the settings**

```auto
     "omschrijving": {
        "type": "search_as_you_type",
        "analyzer": "my_dutch_analyzer", 
        "search_analyzer": "my_search_analyzer"
      },
      "trefwoorden": {
        "type": "text"
      },
      "urn": {
        "type": "text"
      }
    }
      },
      "settings": {
    "index": {
      "routing": {
        "allocation": {
          "include": {
            "_tier_preference": "data_content"
          }
        }
      },
      "number_of_shards": "1"
    },
    "analysis": {
      "analyzer": {
        "my_dutch_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "dutch_stemmer",
            "dutch_stop"
          ]
        },
        "my_search_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "synonyms"
          ]
        }
      },
      "filter": {
        "dutch_stop": {
          "type": "stop",
          "stopwords": "_dutch_"
        },
        "dutch_stemmer": {
          "type": "stemmer",
          "language": "dutch"
        },
        "synonyms": {
          "type": "synonym",
          "synonyms_path": "analysis/synonym.txt",
          "updateable": true
        }
      }
    }
      }
    }

```

Does anyone have an idea of what is going wrong? This is in kibana, using elastic 7.11.1.

---

<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:** [April 27, 2021, 8:57am UTC](https://discuss.elastic.co/t/error-when-querying-on-search-as-you-type-subfields-2gram-3gram/268751/2 "2021-04-27T08:57:31Z")

</div>

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