# Search query in a list of texts

**URL:** https://discuss.elastic.co/t/search-query-in-a-list-of-texts/381625
**Category:** Elasticsearch
**Created:** [September 5, 2025, 7:23am UTC](https://discuss.elastic.co/t/search-query-in-a-list-of-texts/381625 "2025-09-05T07:23:52Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![epistola](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/epistola/32/144908_2.png) [@epistola](https://discuss.elastic.co/u/epistola)
#### Post date: [September 5, 2025, 7:23am UTC](https://discuss.elastic.co/t/search-query-in-a-list-of-texts/381625/1 "2025-09-05T07:23:52Z")

</div>

Hello everyone,

I have a search problem in ES. In the index i have a field that is a list of texts like the following:

list\_field = [text1, text2, text3, …]

I want to search for a number of terms that all belong to the same text entry. If one term is in text1 and another is in text2 for example, the search should not return any results.

Is this possible with the current mapping or do i have to come up with a different representation of this field?

Thanks in advance for any tip.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [September 5, 2025, 7:29am UTC](https://discuss.elastic.co/t/search-query-in-a-list-of-texts/381625/2 "2025-09-05T07:29:05Z")

</div>

> [@epistola](#):
>
> Is this possible with the current mapping or do i have to come up with a different representation of this field?

What is the current mapping for that field?

---

<div class="post-metadata">

### Author: ![epistola](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/epistola/32/144908_2.png) [@epistola](https://discuss.elastic.co/u/epistola)
#### Post date: [September 5, 2025, 8:23am UTC](https://discuss.elastic.co/t/search-query-in-a-list-of-texts/381625/3 "2025-09-05T08:23:45Z")

</div>

Hello @[Christian\_Dahlqvist](https://discuss.elastic.co/u/christian_dahlqvist)

The mapping is:

`"skepseis": {`  
` "type": "text",`  
` "analyzer": "greek"`  
`}`

During the ingest process i build a list with all that texts and send them to ES.

Thank you for answering.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [September 5, 2025, 4:51pm UTC](https://discuss.elastic.co/t/search-query-in-a-list-of-texts/381625/4 "2025-09-05T16:51:47Z")

</div>

As far as I know the functionality you are asking for would require a mapping change, but maybe someone else may have a solution.

---

<div class="post-metadata">

### Author: ![Mark\_Harwood1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood1/32/101255_2.png) [@Mark\_Harwood1](https://discuss.elastic.co/u/Mark_Harwood1)
#### Post date: [September 6, 2025, 9:11am UTC](https://discuss.elastic.co/t/search-query-in-a-list-of-texts/381625/5 "2025-09-06T09:11:46Z")

</div>

I suspect the solution is to use phrase queries and a big “position increment gap”.

Make the phrase queries not require an order and have a “slop” factor greater than the max number of words in a text value but less than the large position increment gap used to put artificial space between the text elements in your array

> **[position\_increment\_gap | Reference](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/position-increment-gap)**
>
> Analyzed text fields take term positions into account, in order to be able to support proximity or phrase queries. When indexing text fields with multiple...

---

<div class="post-metadata">

### Author: ![epistola](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/epistola/32/144908_2.png) [@epistola](https://discuss.elastic.co/u/epistola)
#### Post date: [September 6, 2025, 11:55am UTC](https://discuss.elastic.co/t/search-query-in-a-list-of-texts/381625/6 "2025-09-06T11:55:40Z")

</div>

Hello @Mark_Harwood1

Thank you for your suggestions. I will try them. Hope will fix the issue.

---

<div class="post-metadata">

### Author: ![jesusangel](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jesusangel](https://discuss.elastic.co/u/jesusangel)
#### Post date: [September 7, 2025, 6:37pm UTC](https://discuss.elastic.co/t/search-query-in-a-list-of-texts/381625/7 "2025-09-07T18:37:02Z")

</div>

> [@epistola](#):
>
> list\_field = [text1, text2, text3, …]

Hi there,

If your index is not huge, maybe you can use a script\_query

```auto
GET yourindex/_search
{
  "query": {
    "script_score": {
      "query": {
        "match_all": {}
      },
      "script": {
        "source": """
          String[] terms = new String[] { "γιαούρτι", "ελληνικά" };
          for (item in params._source.list_field) {
            boolean allMatch = true;
            for (term in terms) {
              if (!item.contains(term)) {
                allMatch = false;
                break;
              }
            }
            if (allMatch) return 1.0;
          }
          return 0.0;
        """
      }
    }
  }
}

```

Regards,

---

<div class="post-metadata">

### Author: ![epistola](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/epistola/32/144908_2.png) [@epistola](https://discuss.elastic.co/u/epistola)
#### Post date: [September 9, 2025, 5:34pm UTC](https://discuss.elastic.co/t/search-query-in-a-list-of-texts/381625/8 "2025-09-09T17:34:54Z")

</div>

It seems that position\_increment\_gap is all that i wanted.

Thank you very much.
