# Query\_string DSL fails when just one search term word changes - reliably

**URL:** https://discuss.elastic.co/t/query-string-dsl-fails-when-just-one-search-term-word-changes-reliably/282602
**Category:** Elasticsearch
**Created:** [August 26, 2021, 4:23pm UTC](https://discuss.elastic.co/t/query-string-dsl-fails-when-just-one-search-term-word-changes-reliably/282602 "2021-08-26T16:23:22Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![steveh](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@steveh](https://discuss.elastic.co/u/steveh)
#### Post date: [August 26, 2021, 4:23pm UTC](https://discuss.elastic.co/t/query-string-dsl-fails-when-just-one-search-term-word-changes-reliably/282602/1 "2021-08-26T16:23:22Z")

</div>

Weird problem I cannot explain or solve!

On my production server queries can fail if one word changes. This is reliable. Its just the word change that triggers the error, not a fluke of unfortunate timing (i.e. the server is overloaded)

ES 7.8 with php APi 7.7  
Error: BadRequest400Exception  
Search term: very long search term here and economic  
Query sent as (php print\_r output btw)

```auto
 [query_string] => Array
                                        (
                                            [fields] => Array
                                                (
                                                    [0] => document_content
                                                    [1] => case_summary^10
                                                )

                                            [query] => +very +long +search +term +here +and +economic
                                        )

                                )

```

BUT the query string  
very long search term here and contains  
works fine!  
As does  
very long search term here and continuity  
but NOT  
very long search term here and children

Just changing one word causes the fail, continuity OK, children nope. (those pesky kids)

Any thoughts why this may be? I am bamboozled!

---

<div class="post-metadata">

### Author: ![steveh](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@steveh](https://discuss.elastic.co/u/steveh)
#### Post date: [August 26, 2021, 4:53pm UTC](https://discuss.elastic.co/t/query-string-dsl-fails-when-just-one-search-term-word-changes-reliably/282602/2 "2021-08-26T16:53:45Z")

</div>

p.s. I have just upgraded the PHP API to 7.11 (the latest) via composer, with no affect on the problem. Nor can I find any such thing as reserved words in Elasticsearch.

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [August 30, 2021, 11:26am UTC](https://discuss.elastic.co/t/query-string-dsl-fails-when-just-one-search-term-word-changes-reliably/282602/3 "2021-08-30T11:26:04Z")

</div>

can you share the JSON queries you are sending to Elasticsearch plus the JSON responses coming from Elasticsearch - otherwise debugging this will be super hard.

Thank you!

---

<div class="post-metadata">

### Author: ![steveh](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@steveh](https://discuss.elastic.co/u/steveh)
#### Post date: [August 31, 2021, 8:14am UTC](https://discuss.elastic.co/t/query-string-dsl-fails-when-just-one-search-term-word-changes-reliably/282602/4 "2021-08-31T08:14:07Z")

</div>

I'll see what logging options the PHP API gives me to grab the JSON its sending. I don't use JSON directly.

---

<div class="post-metadata">

### Author: ![steveh](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@steveh](https://discuss.elastic.co/u/steveh)
#### Post date: [August 31, 2021, 4:12pm UTC](https://discuss.elastic.co/t/query-string-dsl-fails-when-just-one-search-term-word-changes-reliably/282602/5 "2021-08-31T16:12:44Z")

</div>

> [@steveh](#):
>
> very long search term here and children

Moving forwards:  
Enabling monolog has revealed this error:

`field doc of [appeals3] index has exceeded [1000000] - maximum allowed to be analyzed for highlighting.`

It appears a few of my documents are much larger than I originally planned for.

Thus am I right in thinking that changing the index from this:  
`"document_content" : { "type" : "text", "analyzer" : "bespoke_snowball" },`  
to this:  
`"document_content" : { "type" : "text", "term_vector" : "with_positions_offsets", "analyzer" : "bespoke_snowball" },`  
and rebuilding my index will magically fix the problem and use the fast highlighter instead?

I realise I could just increase the index.highlight.max\_analyzed\_offset but this would be a "bodgit and run" solution. Adding the term vector appears straight forward.

Your opinion is much appreciated.

Steve

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [September 1, 2021, 8:35am UTC](https://discuss.elastic.co/t/query-string-dsl-fails-when-just-one-search-term-word-changes-reliably/282602/6 "2021-09-01T08:35:50Z")

</div>

Glad you found the issue! Your solution will come at the expense of a bigger index size, but that might be ok for you.

---

<div class="post-metadata">

### Author: ![steveh](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@steveh](https://discuss.elastic.co/u/steveh)
#### Post date: [September 2, 2021, 4:05pm UTC](https://discuss.elastic.co/t/query-string-dsl-fails-when-just-one-search-term-word-changes-reliably/282602/7 "2021-09-02T16:05:14Z")

</div>

Thank you for your help. The fix works and the index size is little different.

---

<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: [September 30, 2021, 4:05pm UTC](https://discuss.elastic.co/t/query-string-dsl-fails-when-just-one-search-term-word-changes-reliably/282602/8 "2021-09-30T16:05:32Z")

</div>

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