# How to use exact match in multi\_match using elasticsearch php

**URL:** <https://discuss.elastic.co/t/how-to-use-exact-match-in-multi-match-using-elasticsearch-php/37448>\
**Category:** Elasticsearch\
**Created:** [December 17, 2015, 8:45am UTC](https://discuss.elastic.co/t/how-to-use-exact-match-in-multi-match-using-elasticsearch-php/37448 "2015-12-17T08:45:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aravinthan\_Asokan](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Aravinthan\_Asokan](https://discuss.elastic.co/u/Aravinthan_Asokan)\
**Post date:** [December 17, 2015, 8:45am UTC](https://discuss.elastic.co/t/how-to-use-exact-match-in-multi-match-using-elasticsearch-php/37448/1 "2015-12-17T08:45:31Z")

</div>

Hi

I have successfully installed and setup the elasticsearch in php using elasticsearch-php client.

Now my challenge is how to do exact match inside multi\_match for all fields.

My php call code below

$multi\_match[] = array('multi\_match' =\> array("query" =\> "xyz abc","operator" =\> "and", "fields" =\> array("a","b","c") ));  
$params['body']['query']["filtered"]['query'] = $multi\_match;  
$response = $client-\>search($params);

how to use double quotes or exact each word search. I want to get result if any one field matches with both two words.

lets say if i have two record

Record 1

1. field a = "xyz abc def" 2) field b = "gggg hhhh" 3) field c = "ssss"

Record 2

1. field a = "xyzzyx abccba deffed" 2) field b = "gggg hhhh" 3) field c = "ssss"

if i use above multi\_match i am getting both record. But i dont want like this i want only the exact match of two words. So i will only get Record 1 ..

How to do ?

---

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [December 17, 2015, 9:01am UTC](https://discuss.elastic.co/t/how-to-use-exact-match-in-multi-match-using-elasticsearch-php/37448/2 "2015-12-17T09:01:24Z")

</div>

You have to tokenize (or just split) the query on your own, than once you have $words array, use a bool query with must and should sub queries:

[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)

---

<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:30pm UTC](https://discuss.elastic.co/t/how-to-use-exact-match-in-multi-match-using-elasticsearch-php/37448/3 "2017-07-05T23:30:19Z")

</div>


