Search/match multiple fields in Elasticsearch

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:

	$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.

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

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