# Intervals wildcard 128 expansion limit

**URL:** <https://discuss.elastic.co/t/intervals-wildcard-128-expansion-limit/256390>\
**Category:** Elasticsearch\
**Created:** [November 23, 2020, 6:44pm UTC](https://discuss.elastic.co/t/intervals-wildcard-128-expansion-limit/256390 "2020-11-23T18:44:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasad.deshpande](https://avatars.discourse-cdn.com/v4/letter/p/bbce88/32.png) [@prasad.deshpande](https://discuss.elastic.co/u/prasad.deshpande)\
**Post date:** [November 23, 2020, 6:44pm UTC](https://discuss.elastic.co/t/intervals-wildcard-128-expansion-limit/256390/1 "2020-11-23T18:44:44Z")

</div>

Hi,

I'm trying out intervals wildcard queries. But in the process, depending on the term I'm hitting the 128 expansion limit. I know that this is a hard limit imposed by Lucene. But my question is if I have to get past it, how do I (Any alternate way)?

This is for the middle wildcards (e.g. `exa*le`), so prefixing/ngraming wouldn't work.

Thanks,  
P

---

<div class="post-metadata">

**Author:** ![prasad.deshpande](https://avatars.discourse-cdn.com/v4/letter/p/bbce88/32.png) [@prasad.deshpande](https://discuss.elastic.co/u/prasad.deshpande)\
**Post date:** [November 25, 2020, 2:57pm UTC](https://discuss.elastic.co/t/intervals-wildcard-128-expansion-limit/256390/2 "2020-11-25T14:57:23Z")

</div>

To elaborate more on the use case, let's say, I've got a query `*ad*ed*` on a field called `description`. Now, we also have description data indexed in sub-field using ngram filter (to avoid leading and trailing wildcards).

So the equivalent ES query gets created as

```
GET documents/_search
{
  "_source": "description",
  "size": 10,
  "query": {
    "intervals": {
      "description": {
        "any_of": {
          "intervals": [
            {
              "all_of": {
                "ordered": true,
                "max_gaps": 0,
                "intervals": [
                  {
                    "match": {
                      "query": "toy"
                    }
                  },
                  {
                    "wildcard": {
                      "pattern": "ad*ed",
                      "use_field": "description._ngram"
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    }
  }
}

```

The above easily throws 128 expansions limit.

I see that Lucene does provide an overridden method to pass an integer as an argument. Can we have something in the method to call that overridden method [here](https://github.com/elastic/elasticsearch/blob/7505d7d61caee245604f3f828925c2346ecc256c/server/src/main/java/org/elasticsearch/index/query/IntervalsSourceProvider.java#L641)?

Also, is there any way to provide say top N (50/100/128) expanded terms instead of throwing an error?

@Alexander_Reelsen @philippk@Alan_Woodward

---

<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:** [December 23, 2020, 2:57pm UTC](https://discuss.elastic.co/t/intervals-wildcard-128-expansion-limit/256390/3 "2020-12-23T14:57:28Z")

</div>

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