# Search/match multiple fields in Elasticsearch

**URL:** <https://discuss.elastic.co/t/search-match-multiple-fields-in-elasticsearch/279448>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [July 23, 2021, 6:52am UTC](https://discuss.elastic.co/t/search-match-multiple-fields-in-elasticsearch/279448 "2021-07-23T06:52:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![noetic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/noetic/32/92029_2.png) [@noetic](https://discuss.elastic.co/u/noetic)\
**Post date:** [July 23, 2021, 6:52am UTC](https://discuss.elastic.co/t/search-match-multiple-fields-in-elasticsearch/279448/1 "2021-07-23T06:52:20Z")

</div>

I'm trying to build a query in `Elasticsearch` with `PHP` combining an exact match and search by keywords/text. I'm using the `should` for an exact match, and for text, I'm using the `term` match.

My query is:

```auto
	$params = [
		'index' => 'sample-vehicles',
		'body' => [
			'query' => [
				'bool' => [
					'should' => [
						['match' => ['abc_vehicle_code' => 'RR']],
						['match' => ['fuel_type' => 'Diesel']],
						['match' => ['manufacturer_city' => 'Chicago']]
					],
					'must' => [
						['term' => ['res_street_1.keyword' => '2213']],
						['term' => ['res_street_2.keyword' => 'Cermak Road']]
					]
				],
			],
		]
	];

```

For an exact match sent in, the `should` gives me appropriate results, but as soon as I place any street address, it gives me `0` records.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 26, 2021, 7:32am UTC](https://discuss.elastic.co/t/search-match-multiple-fields-in-elasticsearch/279448/2 "2021-07-26T07:32:10Z")

</div>

Hey,

this is pretty much impossible to answer without proper documents specified as well? You have not specified how an exact match looks like. With sample docouments like "this matches but should not" or "this does not match but should" the context would be much easier to understand.

Thanks!

--Alex

---

<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:** [August 23, 2021, 7:32am UTC](https://discuss.elastic.co/t/search-match-multiple-fields-in-elasticsearch/279448/3 "2021-08-23T07:32:53Z")

</div>

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