# Search text occurring priority

**URL:** <https://discuss.elastic.co/t/search-text-occurring-priority/217783>\
**Category:** Elasticsearch\
**Created:** [February 4, 2020, 11:16am UTC](https://discuss.elastic.co/t/search-text-occurring-priority/217783 "2020-02-04T11:16:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yash\_Thakkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yash_thakkar/32/62012_2.png) [@Yash\_Thakkar](https://discuss.elastic.co/u/Yash_Thakkar)\
**Post date:** [February 4, 2020, 11:16am UTC](https://discuss.elastic.co/t/search-text-occurring-priority/217783/1 "2020-02-04T11:16:32Z")

</div>

We want to show results based on word position.

e.g. Let's say we have below data in elasticsearch.

```auto
[
  {
      "name": "ANNUALS ASSORTED",
      "code": 3896,
      "color": "",
      "species": "ANNUALS"
  },
  {
      "name": "Rose RED ANNUALS",
      "code": 1,
      "color": "",
      "species": ""
  },
  {
      "name": "ANNUALS PROVEN WINNERS ASSORTED",
      "code": 3898,
      "color": "RED",
      "species": ""
  },
  {
      "name": "ANNUALS PREMIUM ASSORTED",
      "code": 3897,
      "color": "",
      "species": ""
  }
]

```

Now, if the user types A in the search box, first, it should return all the data with name starting with A and then return data where A is occurring on 2 or 3 words.

response:

```auto
[
  {
      "name": "ANNUALS ASSORTED",
      "code": 3896,
      "color": "",
      "species": "ANNUALS"
  },
  {
      "name": "ANNUALS PROVEN WINNERS ASSORTED",
      "code": 3898,
      "color": "RED",
      "species": ""
  },
  {
      "name": "ANNUALS PREMIUM ASSORTED",
      "code": 3897,
      "color": "",
      "species": ""
  },
   {
      "name": "Rose RED ANNUALS",
      "code": 1,
      "color": "",
      "species": ""
  }
]

```

After that, if user search `ann pro`, then it should return result as below.

response:

```auto
[
  {
      "name": "ANNUALS PROVEN WINNERS ASSORTED",
      "code": 3898,
      "color": "RED",
      "species": ""
  },
  {
      "name": "ANNUALS ASSORTED",
      "code": 3896,
      "color": "",
      "species": "ANNUALS"
  },
  {
      "name": "ANNUALS PREMIUM ASSORTED",
      "code": 3897,
      "color": "",
      "species": ""
  },
   {
      "name": "Rose RED ANNUALS",
      "code": 1,
      "color": "",
      "species": ""
  }
]

```

---

<div class="post-metadata">

**Author:** ![Yash\_Thakkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yash_thakkar/32/62012_2.png) [@Yash\_Thakkar](https://discuss.elastic.co/u/Yash_Thakkar)\
**Post date:** [February 6, 2020, 1:22pm UTC](https://discuss.elastic.co/t/search-text-occurring-priority/217783/2 "2020-02-06T13:22:01Z")

</div>

Any update on this?

---

<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:** [March 5, 2020, 1:22pm UTC](https://discuss.elastic.co/t/search-text-occurring-priority/217783/3 "2020-03-05T13:22:03Z")

</div>

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