# Unexpected behaviour with search\_as\_you\_type field indexed as arrays

**URL:** <https://discuss.elastic.co/t/unexpected-behaviour-with-search-as-you-type-field-indexed-as-arrays/253790>\
**Category:** Elasticsearch\
**Created:** [October 30, 2020, 9:18am UTC](https://discuss.elastic.co/t/unexpected-behaviour-with-search-as-you-type-field-indexed-as-arrays/253790 "2020-10-30T09:18:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![serkanozer](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@serkanozer](https://discuss.elastic.co/u/serkanozer)\
**Post date:** [October 30, 2020, 9:18am UTC](https://discuss.elastic.co/t/unexpected-behaviour-with-search-as-you-type-field-indexed-as-arrays/253790/1 "2020-10-30T09:18:36Z")

</div>

```auto
curl -X PUT "localhost:9200/test_index?pretty" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "properties": {
      "search_as_you_type_field": {
        "type": "search_as_you_type"
      }
    }
  }
}
'

curl -X PUT "localhost:9200/test_index/_doc/1?refresh&pretty" -H 'Content-Type: application/json' -d'
{
  "search_as_you_type_field": ["owl", "quick brown fox dog"],
}
'

curl -X PUT "localhost:9200/test_index/_doc/2?refresh&pretty" -H 'Content-Type: application/json' -d'
{
  "search_as_you_type_field": ["quick brown fox dog", "owl"]
}
'

curl -X GET "localhost:9200/test_index/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "match_phrase_prefix": {
      "search_as_you_type_field": {"query": "quick brown fox d"}
    }
  }
}
'
this returns the second document but not the first

```

`match_phrase_prefix` query on a search\_as\_you\_type field doesn't seem to work properly as expected. In the example above first document is indexed with ["owl", "quick brown fox dog"],  
querying `q, qu, qui, .. quick b.. , quick brown f..` works but `quick brown fox d, quick brown fox do, quick brown fox dog` doesn't. However all the possible prefix queries works for the document 1.

I'm not sure this is an expected behavior but seems pretty strange and it is not documented anywhere

---

<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:** [November 27, 2020, 9:18am UTC](https://discuss.elastic.co/t/unexpected-behaviour-with-search-as-you-type-field-indexed-as-arrays/253790/2 "2020-11-27T09:18:48Z")

</div>

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