# Highlight the hit on a large index doing \_all query

**URL:** <https://discuss.elastic.co/t/highlight-the-hit-on-a-large-index-doing--all-query/86567>\
**Category:** Elasticsearch\
**Created:** [May 21, 2017, 11:10am UTC](https://discuss.elastic.co/t/highlight-the-hit-on-a-large-index-doing--all-query/86567 "2017-05-21T11:10:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharongur](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@sharongur](https://discuss.elastic.co/u/sharongur)\
**Post date:** [May 21, 2017, 11:10am UTC](https://discuss.elastic.co/t/highlight-the-hit-on-a-large-index-doing--all-query/86567/1 "2017-05-21T11:10:55Z")

</div>

I need to deliver a POC very fast, because of that i decided to just throw all my information into 1 index.

Now, when i search, for example, a number with a \_all query, i get a very large document.

Is there a way for elastic to highlight on which field the matching occurred?

I look into these [docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-named-queries-and-filters.html), [doc1](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html)[doc2](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#field-match)

But these solutions only highlights a certain field. in my query i use \_all, i dont know which field will hit

Is splitting my index into several indexes \ several types on the same index the only solution?

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [May 26, 2017, 2:09pm UTC](https://discuss.elastic.co/t/highlight-the-hit-on-a-large-index-doing--all-query/86567/2 "2017-05-26T14:09:19Z")

</div>

The short answer is "no", you can't do that with the `_all` field. The `_all` field is really that: a single field that contains the concatenated contents of all other fields. Once the data from other fields is concatenated into `_all`, all information about where it came (or even what kind of data it is, e.g. date vs. number vs. string) is completely lost. It's just a single, big bag of text.

If you need to know what field a query matches, you'll need to maintain multiple fields and search across them. You can do that relatively easily with the [`multi_match`](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html) query, which is designed to search many fields at once.

Then you can use highlighting or query naming in various combinations to achieve what you want.

> [@sharongur](#):
>
> Is splitting my index into several indexes \ several types on the same index the only solution?

This probably isn't required, you just need to keep the fields distinct and search them as independent fields, rather than using the `_all` field.

---

<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 23, 2017, 2:09pm UTC](https://discuss.elastic.co/t/highlight-the-hit-on-a-large-index-doing--all-query/86567/3 "2017-06-23T14:09:21Z")

</div>

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