# Intervals query with or operator

**URL:** <https://discuss.elastic.co/t/intervals-query-with-or-operator/365225>\
**Category:** Elasticsearch\
**Created:** [August 20, 2024, 6:31pm UTC](https://discuss.elastic.co/t/intervals-query-with-or-operator/365225 "2024-08-20T18:31:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kushikawa](https://avatars.discourse-cdn.com/v4/letter/k/8baadc/32.png) [@Kushikawa](https://discuss.elastic.co/u/Kushikawa)\
**Post date:** [August 20, 2024, 6:31pm UTC](https://discuss.elastic.co/t/intervals-query-with-or-operator/365225/1 "2024-08-20T18:31:40Z")

</div>

Hello,  
is it possible to use intervals query with an OR operator logic without using a list of match queries with any\_of rule?

I want to use the intervals positional score for a set of terms, but without the need to loop through each term to construct the query, as I need to pass it as a string parameter in my constructor.

Example:

```auto
{
    "intervals": {
        "title": {
            "any_of": { #or
                "intervals": [
                    {"match": {"query": "smartphone samsung"}},
                    {"match": {"query": "smartphone xiaomi"}}
                ]
            }
        }
    }
}

```

This query gives me the result I want, but I need to pass the terms as one single string query, like

```auto
{
    "intervals": {
        "title": {
            "match": {
                "ordered": false,
                "query": "smartphone samsung xiaomi",
                "operator": "or" #<<<<<
            }
        }
    }
}

```

Thanks in advance

---

<div class="post-metadata">

**Author:** ![S-Dragon0302](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/s-dragon0302/32/100509_2.png) [@S-Dragon0302](https://discuss.elastic.co/u/S-Dragon0302)\
**Post date:** [August 28, 2024, 7:25am UTC](https://discuss.elastic.co/t/intervals-query-with-or-operator/365225/2 "2024-08-28T07:25:54Z")

</div>

intervals query syntax  
{  
"intervals":  
{  
"FilterKeys":  
{  
"all\_of":  
{  
"ordered": true,  
"max\_gaps": 5,  
"intervals":  
[  
{  
"match":  
{  
"query": "hello word",  
"max\_gaps": 0,  
"ordered": true  
}  
},  
{  
"match":  
{  
"query": "how to",  
"max\_gaps": 0,  
"ordered": true  
}  
}  
]  
},  
"boost": 1  
}  
}  
}

intervals\_phrase syntax  
{  
"intervals\_phrase":{  
"query":"((hello word)~0 (how to)~0)~5",  
"field":"FilterKeys",  
"ordered":"true"  
}  
}
