# How to tokenize in this case?

**URL:** <https://discuss.elastic.co/t/how-to-tokenize-in-this-case/43884>\
**Category:** Elasticsearch\
**Created:** [March 9, 2016, 10:07am UTC](https://discuss.elastic.co/t/how-to-tokenize-in-this-case/43884 "2016-03-09T10:07:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnjniG](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@AnjniG](https://discuss.elastic.co/u/AnjniG)\
**Post date:** [March 9, 2016, 10:07am UTC](https://discuss.elastic.co/t/how-to-tokenize-in-this-case/43884/1 "2016-03-09T10:07:42Z")

</div>

Hi all,  
I am searching in an index created through below command  
curl -XPUT '[http://localhost:9200/myTest/](http://localhost:9200/myTest/)' -d '{  
"settings": {  
"index": {  
"number\_of\_shards": 3,  
"number\_of\_replicas": 1,  
"analysis": {  
"analyzer": {  
"myAnalyzer": {  
"tokenizer":"keyword",  
"filter": ["lowercase", "reverse"]  
}  
},  
"filter": {  
"lowercase": {  
"type": "lowercase",  
"preserve\_original": "true"  
},  
"reverse":{  
"type": "reverse"}  
}  
}  
}  
}  
}'

Now in one of the fields in indextypes I have data as below  
"the quick brown fox"  
"the brown quick fox"  
I need to search over these with keywords like "quick brown" which should return only the first one and if i search it like "brown quick" it should only return the 2nd one and not the 1st one.  
How to I achieve this?

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [March 9, 2016, 11:03am UTC](https://discuss.elastic.co/t/how-to-tokenize-in-this-case/43884/2 "2016-03-09T11:03:30Z")

</div>

Hi,

which analyzer do the fields you want to search on use? I suspect its not the one mentioned in your example because the keyword tokenizer won't do any token spliting and reverse the token like this:

```auto
curl -XPOST 'localhost:9200/my_test/_analyze?analyzer=myAnalyzer' -d 'The quick brown fox'
{"tokens":[{"token":"xof nworb kciuq eht","start_offset":0,"end_offset":19,"type":"word","position":0}]}

```

In any case, what you are probably looking for is [Phrase Matching](https://www.elastic.co/guide/en/elasticsearch/guide/current/phrase-matching.html).

Cheers

---

<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:** [July 5, 2017, 11:09pm UTC](https://discuss.elastic.co/t/how-to-tokenize-in-this-case/43884/3 "2017-07-05T23:09:56Z")

</div>


