# Elasticsearch return match fields

**URL:** <https://discuss.elastic.co/t/elasticsearch-return-match-fields/59746>\
**Category:** Elasticsearch\
**Created:** [September 4, 2016, 7:50am UTC](https://discuss.elastic.co/t/elasticsearch-return-match-fields/59746 "2016-09-04T07:50:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mozinrat](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@mozinrat](https://discuss.elastic.co/u/mozinrat)\
**Post date:** [September 4, 2016, 7:50am UTC](https://discuss.elastic.co/t/elasticsearch-return-match-fields/59746/1 "2016-09-04T07:50:24Z")

</div>

I am trying

```auto
GET _search
{
  "query": {
    "match": {
      "_all":"MCRFX"
    }
  }
}

```

I need to find which field the match happened, if that can be found. I am open to use another query, the idea is to search a value in all index and all docs and come up with with relevant doc and field where match happened.

Thanks

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [September 6, 2016, 1:49pm UTC](https://discuss.elastic.co/t/elasticsearch-return-match-fields/59746/2 "2016-09-06T13:49:45Z")

</div>

Have a look at [`named_queries`](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-named-queries-and-filters.html) and [highlighting](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html). Neither of them work super well with the `_all` field but those are how you figure out which field matched.

---

<div class="post-metadata">

**Author:** ![mozinrat](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@mozinrat](https://discuss.elastic.co/u/mozinrat)\
**Post date:** [September 6, 2016, 2:06pm UTC](https://discuss.elastic.co/t/elasticsearch-return-match-fields/59746/3 "2016-09-06T14:06:10Z")

</div>

My document looks like this

```auto
{
        "_index": "edm_demo",
        "_type": "financial_products",
        "_id": "AVbujNiLuNZXbYrTuzVl",
        "_score": 1.8980293,
        "_source": {
          "PROD_ID": 300440,
          "CUSIP": "982967-58-7",
          "SYMBOL": "MCRFX",
          "NAME": "All-Cap Energy & Resources Fund",
          "INDUSTRY": "Legal Services",
          "SHARES": 1948.45,
          "DIVYIELD": 0.56032,
          "HIGH": 4428.29,
          "LOW": 3985.46,
          "VOLUME": 3764.05,
          "CHANGE": 0.623993
        }
      }

```

I tried many highlight queries even without all some like

```auto
GET edm_demo/financial_products/_search
{
  "query": {
    "query_string": {
      "query":"MCRFX"
    }
  },
  "highlight": {
    "title": {
      "number_of_fragments":0
    } }
}

```

But I got no success, in Kibana -sense I can't see a thing. Is it some issue of kibana or there is no highlight resulted expected out of it.  
I can't figured out how to use named query in my conditions as I don't even have field names with me.

I am trying to dump a database in elasticsearch, when user search a value I want to show which table and which column had that value. The alternate solution I got is to dump in column based index only, but then each document has just one value. Is it a good strategy?. Any suggestions are really appreciated.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [September 6, 2016, 2:24pm UTC](https://discuss.elastic.co/t/elasticsearch-return-match-fields/59746/4 "2016-09-06T14:24:18Z")

</div>

Next time can you wrap code blocks in ```? It makes them easier to read. I've used my admin powers to edit your post above.

As to your highlighting problems, have a look at [`required_field_match`](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#field-match).

---

<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, 10:22pm UTC](https://discuss.elastic.co/t/elasticsearch-return-match-fields/59746/5 "2017-07-05T22:22:17Z")

</div>


