# Highlighting issues

**URL:** <https://discuss.elastic.co/t/highlighting-issues/69980>\
**Category:** Elasticsearch\
**Created:** [December 26, 2016, 7:44am UTC](https://discuss.elastic.co/t/highlighting-issues/69980 "2016-12-26T07:44:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![enp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enp/32/3825_2.png) [@enp](https://discuss.elastic.co/u/enp)\
**Post date:** [December 26, 2016, 7:44am UTC](https://discuss.elastic.co/t/highlighting-issues/69980/1 "2016-12-26T07:44:09Z")

</div>

Hi,

I tried to highlight search results:

```
POST one/two
{
  "name": "Jonn Doe"
}

GET one/two/_search
{
  "query": {
    "query_string": {
      "analyze_wildcard": true,
      "query": "*Doe*"
    }
  },
  "highlight": {
    "fields": {
      "_all": {}
    }
  }
}

```

But I can't see highlighted results:

```
{
  "took": 3,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "one",
        "_type": "two",
        "_id": "AVk5uY9jRC6_QLkwtbju",
        "_score": 1,
        "_source": {
          "name": "Jonn Doe"
        }
      }
    ]
  }
}

```

What's wrong?

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [December 26, 2016, 4:05pm UTC](https://discuss.elastic.co/t/highlighting-issues/69980/2 "2016-12-26T16:05:42Z")

</div>

Have you seen the note at the top of the [highlighting documentation](https://www.elastic.co/guide/en/elasticsearch/reference/5.1/search-request-highlighting.html#search-request-highlighting) page?

> In order to perform highlighting, the actual content of the field is required. If the field in question is stored (has ` store` set to `true` in the mapping) it will be used, otherwise, the actual `_source` will be loaded and the relevant field will be extracted from it.

> The `_all` field cannot be extracted from `_source`, so it can only be used for highlighting if it mapped to have store set to true.

---

<div class="post-metadata">

**Author:** ![enp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enp/32/3825_2.png) [@enp](https://discuss.elastic.co/u/enp)\
**Post date:** [December 26, 2016, 7:09pm UTC](https://discuss.elastic.co/t/highlighting-issues/69980/3 "2016-12-26T19:09:12Z")

</div>

Can't understand ☹

My mapping looks like:

```
{
  "one": {
    "mappings": {
      "two": {
        "properties": {
          "name": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    }
  }
}

```

Is field 'name' stored or no? Need I add 'store' attribute for it? Btw, I tried use 'name' instead of '\_all', but result was the same. So, can you show me what I need to fix in my example to see highlighting?

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [December 26, 2016, 8:52pm UTC](https://discuss.elastic.co/t/highlighting-issues/69980/4 "2016-12-26T20:52:34Z")

</div>

> [@enp](#):
>
> Is field 'name' stored or no?

No, it's not stored by default separately, but content can be extracted from `_source`. So, it is not the issue.

> [@enp](#):
>
> Btw, I tried use 'name' instead of '\_all', but result was the same.

Unless you also specified `name` in the query, your search was executed against the field `_all`. By default, highlighting only works with the fields you are searching against. So, you can do something like

```auto
GET one/two/_search
{
  "query": {
    "query_string": {
      "analyze_wildcard": true,
      "query": "name:*Doe*"
    }
  },
  "highlight": {
    "fields": {
      "name": {}
    }
  }
}

```

Or you can disable this behavior using [`require_field_match`](https://www.elastic.co/guide/en/elasticsearch/reference/5.1/search-request-highlighting.html#field-match) parameter and highlight any field:

```auto
GET one/two/_search
{
  "query": {
    "query_string": {
      "analyze_wildcard": true,
      "query": "*Doe*"
    }
  },
  "highlight": {
    "require_field_match": false,
    "fields": {
      "name": { }
    }
  }
}

```

Or you can store `_all` field, by recreating your index

```auto
DELETE one

PUT one
{
  "mappings": {
    "two": {
      "_all": {
        "store": "yes"
      }
    }
  }
}

POST one/two
{
  "name": "Jonn Doe"
}

GET one/two/_search
{
  "query": {
    "query_string": {
      "analyze_wildcard": true,
      "query": "*Doe*"
    }
  },
  "highlight": {
    "fields": {
      "_all": {}
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![enp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enp/32/3825_2.png) [@enp](https://discuss.elastic.co/u/enp)\
**Post date:** [December 27, 2016, 4:46am UTC](https://discuss.elastic.co/t/highlighting-issues/69980/5 "2016-12-27T04:46:27Z")

</div>

Thank you

---

<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:** [January 24, 2017, 4:46am UTC](https://discuss.elastic.co/t/highlighting-issues/69980/6 "2017-01-24T04:46:28Z")

</div>

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