# Search\_as\_you\_type field as subfield

**URL:** <https://discuss.elastic.co/t/search-as-you-type-field-as-subfield/300425>\
**Category:** Elasticsearch\
**Created:** [March 23, 2022, 8:59am UTC](https://discuss.elastic.co/t/search-as-you-type-field-as-subfield/300425 "2022-03-23T08:59:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casparxu](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@casparxu](https://discuss.elastic.co/u/casparxu)\
**Post date:** [March 23, 2022, 8:59am UTC](https://discuss.elastic.co/t/search-as-you-type-field-as-subfield/300425/1 "2022-03-23T08:59:44Z")

</div>

Hello experts,  
I'm using ES v7. I noticed there's a fantastic type called 'search\_ar\_you\_type' can help me with auto-completion. The samples from doc is map the field to this type like:

```auto
{
  "mappings": {
    "properties": {
      "my_field": {
        "type": "search_as_you_type"
      }
    }
  }
}

```

As I don't want to change my current index mapping, the property type is "text", can I add a subfield with 'search\_as\_you\_type' type? like this

```auto
{
  "mappings": {
    "properties": {
      "my_field": {
        "type": "text",
        "fields": {
          "sayt": {
            "type": "search_as_you_type"
          }
        }
      }
    }
  }
}

```

I ask this because I know 'search\_as\_you\_type' itself also add subfields like '\_2gram' and etc, which are like subfield of subfield, and I'm not sure this works well or not.  
Thanks

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 23, 2022, 11:02am UTC](https://discuss.elastic.co/t/search-as-you-type-field-as-subfield/300425/2 "2022-03-23T11:02:52Z")

</div>

yes, you just append the fieldnames, using dots.. like `my_field.sayt._2gram`. Note that there was an issue if you define the main field to be search as you type containing other multi fields, that has only been sovled in 8.1, see [Search as you type field to support subfields by javanna · Pull Request #82430 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/pull/82430)

---

<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 20, 2022, 11:02am UTC](https://discuss.elastic.co/t/search-as-you-type-field-as-subfield/300425/3 "2022-04-20T11:02:55Z")

</div>

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