# Elasticsearch multi match

**URL:** <https://discuss.elastic.co/t/elasticsearch-multi-match/121380>\
**Category:** Elasticsearch\
**Created:** [February 25, 2018, 12:50pm UTC](https://discuss.elastic.co/t/elasticsearch-multi-match/121380 "2018-02-25T12:50:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![svarup](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@svarup](https://discuss.elastic.co/u/svarup)\
**Post date:** [February 25, 2018, 12:50pm UTC](https://discuss.elastic.co/t/elasticsearch-multi-match/121380/1 "2018-02-25T12:50:58Z")

</div>

I have index with dynamic mapping

```auto
'mappings' => [
	'index_type' => [
		'dynamic_templates' => [
			[
				'property_name' => [
				   'match_mapping_type' => '*',
				   'match' => 'name_property_*',
				   'mapping' => [
					'type' => 'text',
					'index'	=> TRUE,
				   ],
                                ],
			],
		],
	],
],

```

Now i queried like this

```auto
[
	'size' => 1,
	'from' => 0,
	'_source' => [],
	'query' => [
		'multi_match' => [
		'query' => 'query',
		'type' => 'best_fields',
		'fields' => ['name_property_*'],
	],
],

```

and query successfully executed like this

```auto
 ['_index'] => 'index_name'
 ['_type'] => 'index_type'
 ['_id'] => 1325
 ['_score'] => 0.28
 ['_source'] => Array
 (
     ['name_property_1'] => 'country',
     ['name_property_2'] => 'query',
     ['name_property_3'] => 'state'
 )

```

Now my question is how to return only fields that match the actual query in this example how to achieve output like this

```auto
['_index'] => 'index_name'
['_type'] => 'index_type'
['_id'] => 1325
['_score'] => 0.28
['_source'] => Array
(
    ['name_property_2'] => 'query',
)

```

only name\_property\_2 because this field only match with the query i do not want to return whole document.

---

<div class="post-metadata">

**Author:** ![aclowkey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclowkey/32/51020_2.png) [@aclowkey](https://discuss.elastic.co/u/aclowkey)\
**Post date:** [February 25, 2018, 8:12pm UTC](https://discuss.elastic.co/t/elasticsearch-multi-match/121380/2 "2018-02-25T20:12:14Z")

</div>

Maybe try to highlight on the fields. I'm not sure, but I think the highlighter will only return the matched. You can combine that with "\_source": false and just get the highlighted fields

---

<div class="post-metadata">

**Author:** ![svarup](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@svarup](https://discuss.elastic.co/u/svarup)\
**Post date:** [March 1, 2018, 8:56am UTC](https://discuss.elastic.co/t/elasticsearch-multi-match/121380/3 "2018-03-01T08:56:29Z")

</div>

yes thanks @aclowkey highlighter is worked. 😀

---

<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:** [March 29, 2018, 8:56am UTC](https://discuss.elastic.co/t/elasticsearch-multi-match/121380/4 "2018-03-29T08:56:35Z")

</div>

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