# Phrase/ multi-worlds search

**URL:** <https://discuss.elastic.co/t/phrase-multi-worlds-search/274661>\
**Category:** Elasticsearch\
**Created:** [June 1, 2021, 3:43pm UTC](https://discuss.elastic.co/t/phrase-multi-worlds-search/274661 "2021-06-01T15:43:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lalitesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lalitesh/32/84165_2.png) [@lalitesh](https://discuss.elastic.co/u/lalitesh)\
**Post date:** [June 1, 2021, 3:43pm UTC](https://discuss.elastic.co/t/phrase-multi-worlds-search/274661/1 "2021-06-01T15:43:01Z")

</div>

I am trying to implement a use case wherein a user can make a multi-words/ phrase search for 'product\_name' field.

Assuming someone is searching for 'Richest Man', the following results should come:

- The Richest Man in Babylon
- Story of the Richest man
- The richest man in the world
- How to win the richest man

Search result must not include the following docs-

- Richest woman and man
- When a poor man becomes the richest

Here is the analyser that I wrote:  
`  
'settings' =\> [  
'analysis' =\> [  
'filter' =\> [  
'autocomplete\_filter' =\> ['type' =\> 'ngram', 'min\_gram' =\> 1, 'max\_gram' =\> 10]  
],  
'analyzer' =\> [  
'autocomplete' =\> ['type' =\> 'custom', 'tokenizer' =\> 'standard', 'filter' =\> ['lowercase', 'autocomplete\_filter']]  
]  
],  
'index.max\_ngram\_diff' =\> 10  
],  
'mappings' =\> ['properties' =\> [  
'product\_name' =\> ['type' =\> 'text', 'analyzer' =\> 'autocomplete', 'search\_analyzer', 'standard'],  
]],

and I am using the following code, written in PHP to make a search request:

`  
$params = [  
'index' =\> ProductData::ELASTIC\_INDEX,  
'type' =\> ProductData::ELASTIC\_TYPE,  
'body' =\> [  
'query' =\> ['match' =\> ['product\_name' =\> ['query' =\> $requestVars['product\_name']]]  
],  
]  
];

$result = $this-\>client-\>search($params);  
`

**If I search for "richest m" or "hest man" I should get those 4 results. If I search for "richest", "ches" or "ma" I should be seeing all the results i.e. 6 documents.**

However, the result that I am getting is unexpected and not the ones that I listed above.

---

<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 29, 2021, 3:43pm UTC](https://discuss.elastic.co/t/phrase-multi-worlds-search/274661/2 "2021-06-29T15:43:57Z")

</div>

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