# Fuzziness support in intervals query?

**URL:** <https://discuss.elastic.co/t/fuzziness-support-in-intervals-query/208935>\
**Category:** Elasticsearch\
**Created:** [November 21, 2019, 4:35pm UTC](https://discuss.elastic.co/t/fuzziness-support-in-intervals-query/208935 "2019-11-21T16:35:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [November 21, 2019, 4:35pm UTC](https://discuss.elastic.co/t/fuzziness-support-in-intervals-query/208935/1 "2019-11-21T16:35:58Z")

</div>

ES 7.0 introduced support for the [Lucene `intervals` query](https://www.elastic.co/blog/elasticsearch-7-0-0-beta1-released) which is more powerful and easier to deal with than `span` queries (analyzer support, etc). However, one thing that `span` queries support and `intervals` doesn't is fuzziness. Since the `intervals` query is supposed to help in legal and patent search, I have a hard time understanding how this could be possible without fuzziness support.

I could not find much information about that when browsing the [Github](https://github.com/elastic/elasticsearch/pull/36135) [issues](https://github.com/elastic/elasticsearch/issues/29636). Is there any reason why the `intervals` query doesn't support fuzziness? (because [Lucene doesn't](https://issues.apache.org/jira/browse/LUCENE-8284) maybe)? Is it on the roadmap?

Here was a another sample case where fuzziness support in `intervals` query could come in handy.

> [@How to filter data despite the spelling mistake and according to the max gap between passed words](https://discuss.elastic.co/t/how-to-filter-data-despite-the-spelling-mistake-and-according-to-the-max-gap-between-passed-words/208092):
>
> If I have these two strings: George Orwell is my favorite writer My favorite writers name is George, who was born in 1903 and whose last name is Orwell Here's the criteria that i would like to apply to my search when searching for 2+ words: search despite spelling mistake (whats does fuzziness) filter result according distance between passed words (for example in first sentence distance between George and Orwell is 0, cause they are side by side, and in second one I have 10 other words…

---

<div class="post-metadata">

**Author:** ![Mikhail\_Khludnev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikhail_khludnev/32/59591_2.png) [@Mikhail\_Khludnev](https://discuss.elastic.co/u/Mikhail_Khludnev)\
**Post date:** [November 21, 2019, 8:34pm UTC](https://discuss.elastic.co/t/fuzziness-support-in-intervals-query/208935/2 "2019-11-21T20:34:07Z")

</div>

Hello, Val.

After [https://issues.apache.org/jira/browse/LUCENE-9028](https://issues.apache.org/jira/browse/LUCENE-9028) it's comparatively easy to make fuzzy intervals in Elastic. Although, there is one severe lack in intervals at comparison to spans.

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [November 25, 2019, 9:10am UTC](https://discuss.elastic.co/t/fuzziness-support-in-intervals-query/208935/3 "2019-11-25T09:10:41Z")

</div>

@Adrien_Grand I'd really appreciate if you could provide some insights. Thank you very much in advance!

---

<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 26, 2019, 1:56pm UTC](https://discuss.elastic.co/t/fuzziness-support-in-intervals-query/208935/4 "2019-11-26T13:56:00Z")

</div>

@Mikhail_Khludnev, @Adrien_Grand, I totally agree with @val. Even I need to use Fuzzy support with interval queries. Could you please suggest something?

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [November 26, 2019, 2:02pm UTC](https://discuss.elastic.co/t/fuzziness-support-in-intervals-query/208935/5 "2019-11-26T14:02:58Z")

</div>

I think it's worth opening an issue in Elasticsearch and we'll discuss where the support should land (Elasticsearch or Lucene). As @Mikhail_Khludnev suggested it should be easy to make fuzzy intervals in Elasticsearch using the MultiTermIntervalsSource except that it is not exposed 😉. Queries that need to check positions cannot handle large number of multi-terms so we have some logic to restrict to those that expand to less than a provided threshold (bounded to 1024). With this protection in place I don't see why we should not expose them more simply in Lucene.

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [November 26, 2019, 2:08pm UTC](https://discuss.elastic.co/t/fuzziness-support-in-intervals-query/208935/6 "2019-11-26T14:08:48Z")

</div>

@jimczi  
Thank you so much for shedding some light on this! That's good news!

As suggested, I've created the new issue: [https://github.com/elastic/elasticsearch/issues/49595](https://github.com/elastic/elasticsearch/issues/49595)

---

<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 24, 2019, 2:09pm UTC](https://discuss.elastic.co/t/fuzziness-support-in-intervals-query/208935/7 "2019-12-24T14:09:00Z")

</div>

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