# Can search\_as\_you\_type field show the prefix match results firstly

**URL:** <https://discuss.elastic.co/t/can-search-as-you-type-field-show-the-prefix-match-results-firstly/309083>\
**Category:** Elasticsearch\
**Created:** [July 7, 2022, 7:29am UTC](https://discuss.elastic.co/t/can-search-as-you-type-field-show-the-prefix-match-results-firstly/309083 "2022-07-07T07:29:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhengpq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhengpq/32/108008_2.png) [@zhengpq](https://discuss.elastic.co/u/zhengpq)\
**Post date:** [July 7, 2022, 7:29am UTC](https://discuss.elastic.co/t/can-search-as-you-type-field-show-the-prefix-match-results-firstly/309083/1 "2022-07-07T07:29:47Z")

</div>

i am using the search\_as\_you\_type to auto complete, it is good, but i find the result is sorted by the score, now i need the prefix match results to come firstly, look the example blow:

```auto
POST page-new/_search
{
  "_source": {
    "includes": [
      "page_title",
      "release_status",
      "frame_id"
    ]
  },
  "size": 100, 
  "query": {
    "match_phrase_prefix": {
      "page_title.suggest_full": "流量主"
    }
  }
}

```

here is the result

```auto
 "hits" : [
      {
        "_index" : "wxad-page-new",
        "_type" : "_doc",
        "_id" : "314",
        "_score" : 5.161003,
        "_source" : {
          "page_title" : "开通流量主",
          "release_status" : 1,
          "frame_id" : 12
        }
      },
      {
        "_index" : "wxad-page-new",
        "_type" : "_doc",
        "_id" : "318",
        "_score" : 4.7886534,
        "_source" : {
          "page_title" : "流量主常见问题",
          "release_status" : 1,
          "frame_id" : 12
        }
      }
]

```

the second hit is prefix match result, i want it to show first, how can i do to make this happen.

---

<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:** [August 4, 2022, 7:30am UTC](https://discuss.elastic.co/t/can-search-as-you-type-field-show-the-prefix-match-results-firstly/309083/2 "2022-08-04T07:30:12Z")

</div>

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