# Querying for length of document

**URL:** <https://discuss.elastic.co/t/querying-for-length-of-document/304833>\
**Category:** Elasticsearch\
**Created:** [May 16, 2022, 2:30pm UTC](https://discuss.elastic.co/t/querying-for-length-of-document/304833 "2022-05-16T14:30:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomZa](https://avatars.discourse-cdn.com/v4/letter/t/46a35a/32.png) [@TomZa](https://discuss.elastic.co/u/TomZa)\
**Post date:** [May 16, 2022, 2:30pm UTC](https://discuss.elastic.co/t/querying-for-length-of-document/304833/1 "2022-05-16T14:30:08Z")

</div>

Hi,

I have documents indexed like this:

> "words": "Yellow dogs are barking"

The example above has four tokens. While querying now via matchPhrase, is it possible to set a minimum of tokens which should be in the document? (Its not an array).

Thanks a lot,

Tom

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 17, 2022, 2:02am UTC](https://discuss.elastic.co/t/querying-for-length-of-document/304833/2 "2022-05-17T02:02:29Z")

</div>

Welcome to our community! 😃

Does [minimum\_should\_match parameter | Elasticsearch Guide [8.2] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/8.2/query-dsl-minimum-should-match.html) look like it would do what you want?

---

<div class="post-metadata">

**Author:** ![TomZa](https://avatars.discourse-cdn.com/v4/letter/t/46a35a/32.png) [@TomZa](https://discuss.elastic.co/u/TomZa)\
**Post date:** [May 17, 2022, 9:12am UTC](https://discuss.elastic.co/t/querying-for-length-of-document/304833/3 "2022-05-17T09:12:14Z")

</div>

Thanks, but it does not qork:

> "reason": "[match\_phrase] query does not support [minimum\_should\_match]",

My query:

> {  
> "query": {  
> "match\_phrase": {  
> "token": {  
> "query" : "Salz und Pfeffer",  
> "minimum\_should\_match" : 20,  
> "slop" : 3  
> }  
> }  
> },  
> "\_source": true,  
> "size" : 10
> 
> }

---

<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:** [June 14, 2022, 9:12am UTC](https://discuss.elastic.co/t/querying-for-length-of-document/304833/4 "2022-06-14T09:12:18Z")

</div>

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