# \[ES 5.0\] Simple Query String - highlight issue

**URL:** <https://discuss.elastic.co/t/es-5-0-simple-query-string-highlight-issue/68752>\
**Category:** Elasticsearch\
**Created:** [December 12, 2016, 6:57pm UTC](https://discuss.elastic.co/t/es-5-0-simple-query-string-highlight-issue/68752 "2016-12-12T18:57:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![evert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/evert/32/8143_2.png) [@evert](https://discuss.elastic.co/u/evert)\
**Post date:** [December 12, 2016, 6:57pm UTC](https://discuss.elastic.co/t/es-5-0-simple-query-string-highlight-issue/68752/1 "2016-12-12T18:57:05Z")

</div>

I have some pdf file indexed and I am using _simple\_query\_string_ in order to use the very nice features of +, -, | etc.

So here is my search script:

```
[
    'stored_fields' => ['name', 'author', 'editor', 'url'],
    'query' => [
        'simple_query_string' => [
            'query'=> $search_text,
            'fields'=> ['attachment.content^5','_all'],
            'default_operator'=> 'and',
        ]
],
'highlight' => [
    'number_of_fragments' => $fragnumber,
    'fragment_size' => $fragsize,
    'pre_tags' => [
        "<em><mark>"
    ],
    'post_tags' => [
        "</mark></em>"
    ],
    'fields' => [

        'attachment.content' => new \stdClass()
    ]
]

```

The [example in the docs](https://www.elastic.co/guide/en/elasticsearch/reference/5.1/query-dsl-simple-query-string-query.html) it uses double quotes (") in the query.

So, when I search for a term without double quotes, as of: **paulo de tarso** it brings the results acoordingly with the _hightlights_.

If I use the double quotes as of: **"paulo de tarso"** it does not show the _highlights_....

Has anyone faced this same issue?

Thanks!

---

<div class="post-metadata">

**Author:** ![evert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/evert/32/8143_2.png) [@evert](https://discuss.elastic.co/u/evert)\
**Post date:** [December 12, 2016, 6:58pm UTC](https://discuss.elastic.co/t/es-5-0-simple-query-string-highlight-issue/68752/2 "2016-12-12T18:58:12Z")

</div>

Would it be because of the stop word "de" of the portuguese language?

Shouldn´t the quotes means that to do not ignore any word?

---

<div class="post-metadata">

**Author:** ![evert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/evert/32/8143_2.png) [@evert](https://discuss.elastic.co/u/evert)\
**Post date:** [December 22, 2016, 12:57am UTC](https://discuss.elastic.co/t/es-5-0-simple-query-string-highlight-issue/68752/3 "2016-12-22T00:57:47Z")

</div>

For the record, the problem was my _attachment.content_ was mapped to use the option:

**"term\_vector" : "with\_positions\_offsets",**

Which does not work with that type of query somehow... not sure if this is a bug or is the expected.

Cheers!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 22, 2016, 10:06am UTC](https://discuss.elastic.co/t/es-5-0-simple-query-string-highlight-issue/68752/4 "2016-12-22T10:06:33Z")

</div>

Hi @evert

What is wrong with using this option? I mean this is what we advice at [https://www.elastic.co/guide/en/elasticsearch/plugins/5.1/mapper-attachments-highlighting.html](https://www.elastic.co/guide/en/elasticsearch/plugins/5.1/mapper-attachments-highlighting.html)

Can you reproduce the problem entirely using a pure REST script?

---

<div class="post-metadata">

**Author:** ![evert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/evert/32/8143_2.png) [@evert](https://discuss.elastic.co/u/evert)\
**Post date:** [December 22, 2016, 10:28am UTC](https://discuss.elastic.co/t/es-5-0-simple-query-string-highlight-issue/68752/5 "2016-12-22T10:28:08Z")

</div>

Hello @dadoonet,

I can send you full report later on this weekend, but here is in a few word... when using brazilian analyzer in the attachment.content field, using this option, in my search it will not bring the highlight... even using the simple query in the highlight\_query.

This is what happened.

I will report this issue with all examples and reproduce test, so you guys can check.

A little exhastive after 4 days of research and tests.. I read ALL documentation so far... and will have to re index all my data, 500 pdf books, site will get in production by next week.

Cheers!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 22, 2016, 10:40am UTC](https://discuss.elastic.co/t/es-5-0-simple-query-string-highlight-issue/68752/6 "2016-12-22T10:40:19Z")

</div>

May be this is something related to the analyzer. Did you check what is produced exactly by running a `_analyze` API?

---

<div class="post-metadata">

**Author:** ![evert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/evert/32/8143_2.png) [@evert](https://discuss.elastic.co/u/evert)\
**Post date:** [December 25, 2016, 2:17pm UTC](https://discuss.elastic.co/t/es-5-0-simple-query-string-highlight-issue/68752/7 "2016-12-25T14:17:19Z")

</div>

Hello @dadoonet,

Just see your message today. Merry Christmas!

I will check that and reply as well.

I am preparing to send as an issue in github, so you guys can check everything.

Thanks!

---

<div class="post-metadata">

**Author:** ![evert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/evert/32/8143_2.png) [@evert](https://discuss.elastic.co/u/evert)\
**Post date:** [December 25, 2016, 10:34pm UTC](https://discuss.elastic.co/t/es-5-0-simple-query-string-highlight-issue/68752/8 "2016-12-25T22:34:50Z")

</div>

Hi @dadoonet,

I opened an issue with the most complete sample as I could. Please let me know if I can improve it.

> <https://github.com/elastic/elasticsearch/issues/22346>

Cheers!

---

<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 22, 2017, 10:34pm UTC](https://discuss.elastic.co/t/es-5-0-simple-query-string-highlight-issue/68752/9 "2017-01-22T22:34:50Z")

</div>

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