# Search\_as\_you\_type not working, help

**URL:** <https://discuss.elastic.co/t/search-as-you-type-not-working-help/282111>\
**Category:** Elasticsearch\
**Created:** [August 20, 2021, 6:06pm UTC](https://discuss.elastic.co/t/search-as-you-type-not-working-help/282111 "2021-08-20T18:06:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![michel.st-louis](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@michel.st-louis](https://discuss.elastic.co/u/michel.st-louis)\
**Post date:** [August 20, 2021, 6:06pm UTC](https://discuss.elastic.co/t/search-as-you-type-not-working-help/282111/1 "2021-08-20T18:06:38Z")

</div>

I was trying the new feature Search\_as\_you\_type but I don't know if if it my lack of knowledge but it is not working. I installed the verion 7.14. this is my kibana queries. this query yeld nothing no hits.

```auto
DELETE test
PUT test
{
  "mappings": {
    "properties": {
      "id": {
        "type": "keyword"
      },
      "content": {
        "type": "search_as_you_type"
      }
    }
  }
}

```

```auto
POST test/_doc
{
  "id" : "my dog is a great search engine"
}

```

```auto
GET test/_search
{
  "query": {
    "multi_match": {
      "query": "search engine",
      "type": "bool_prefix",
      "fields": [
        "content",
        "content._2gram",
        "content._3gram"
      ]
    }
  }
}

```

---

<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 20, 2021, 11:46pm UTC](https://discuss.elastic.co/t/search-as-you-type-not-working-help/282111/2 "2021-08-20T23:46:39Z")

</div>

Hi @michel.st-louis Welcome to the community!

Oops... put your data in the wrong field should be in the `content` field not the `id` field 🙂

```auto
POST test/_doc
{
  "id" : "my dog is a great search engine"
}

```

Should be

```auto
POST test/_doc
{
  "content" : "my dog is a great search engine"
}

```

So now...

```auto
GET test/_search
{
  "query": {
    "multi_match": {
      "query": "search engine",
      "type": "bool_prefix",
      "fields": [
        "content",
        "content._2gram",
        "content._3gram"
      ]
    }
  }
}

```

Result

```auto
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 2.287682,
    "hits" : [
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "JNzyZXsBmmhzZ_AM3A6p",
        "_score" : 2.287682,
        "_source" : {
          "content" : "my dog is a great search engine"
        }
      }
    ]
  }
}

```

---

<div class="post-metadata">

**Author:** ![michel.st-louis](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@michel.st-louis](https://discuss.elastic.co/u/michel.st-louis)\
**Post date:** [August 23, 2021, 11:01am UTC](https://discuss.elastic.co/t/search-as-you-type-not-working-help/282111/3 "2021-08-23T11:01:26Z")

</div>

Your right !! now I get results. I had my eyes on the tree not the forest! but I still don't understand why this field is called search\_as\_you\_type it return all the content field, am I going to have to index every words ? If I type lets say "gre" the search should come out with "great" or "great search".

---

<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 23, 2021, 5:06pm UTC](https://discuss.elastic.co/t/search-as-you-type-not-working-help/282111/4 "2021-08-23T17:06:02Z")

</div>

I think you need to experiment this search will return the document as well

```auto
GET test/_search
{
  "query": {
    "multi_match": {
      "query": "gre",
      "type": "bool_prefix",
      "fields": [
        "content",
        "content._2gram",
        "content._3gram"
      ]
    }
  }
}

```

> [@michel.st-louis](#):
>
> am I going to have to index every words ?

Apologies, I am unclear exactly what you mean...

---

<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 20, 2021, 5:06pm UTC](https://discuss.elastic.co/t/search-as-you-type-not-working-help/282111/5 "2021-09-20T17:06:09Z")

</div>

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