# Token count query and its correlation with field

**URL:** <https://discuss.elastic.co/t/token-count-query-and-its-correlation-with-field/177332>\
**Category:** Elasticsearch\
**Created:** [April 17, 2019, 3:26pm UTC](https://discuss.elastic.co/t/token-count-query-and-its-correlation-with-field/177332 "2019-04-17T15:26:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pokaleshrey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pokaleshrey/32/48680_2.png) [@pokaleshrey](https://discuss.elastic.co/u/pokaleshrey)\
**Post date:** [April 17, 2019, 3:26pm UTC](https://discuss.elastic.co/t/token-count-query-and-its-correlation-with-field/177332/1 "2019-04-17T15:26:42Z")

</div>

I have a mapping as below. The text field below is actually an array of different values of different word length.

> {  
> "docs": {  
> "mappings": {  
> "doc": {  
> "properties": {  
> "name": {  
> "type": "text",  
> "fields": {  
> "length": {  
> "type": "token\_count",  
> "analyzer": "standard"  
> }  
> }  
> }  
> }  
> }  
> }  
> }  
> }

If i have many values in the "name" array, i have multiple "length" values generated by token\_count field.

On querying with name="John Walker" and name.length=3, it still gives results. That is because there is another name called "Bishop Rook Knight" in it.

How do i maintain correlation between name and length ?

---

<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:** [May 15, 2019, 3:26pm UTC](https://discuss.elastic.co/t/token-count-query-and-its-correlation-with-field/177332/2 "2019-05-15T15:26:45Z")

</div>

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