# Error "type": "query\_shard\_exception" while running below query in dev tools

**URL:** <https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666>\
**Category:** Elasticsearch\
**Created:** [June 20, 2019, 11:12am UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666 "2019-06-20T11:12:08Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![pyerunka](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@pyerunka](https://discuss.elastic.co/u/pyerunka)\
**Post date:** [June 20, 2019, 11:12am UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666/1 "2019-06-20T11:12:08Z")

</div>

Hello,

I am running below query:

> GET new\_master\_query/\_search  
> {  
> "query": {  
> "multi\_match": {  
> "query": "Geosolutions",  
> "fields": ["contentid^4", "title^3","object\_summary^2","submitted\_for\_name"] }  
> }  
> }

and i am getting below error:

{

> "error": {  
> "root\_cause": [  
> {  
> "type": "query\_shard\_exception",  
> "reason": "failed to create query: {\n "multi\_match" : {\n "query" : "Geosolutions",\n "fields" : [\n "contentid^4.0",\n "object\_summary^2.0",\n "submitted\_for\_name^1.0",\n "title^3.0"\n],\n "type" : "best\_fields",\n "operator" : "OR",\n "slop" : 0,\n "prefix\_length" : 0,\n "max\_expansions" : 50,\n "zero\_terms\_query" : "NONE",\n "auto\_generate\_synonyms\_phrase\_query" : true,\n "fuzzy\_transpositions" : true,\n "boost" : 1.0\n }\n}",  
> "index\_uuid": "yNcq1TcCQWGb0BXGHx2ORg",  
> "index": "new\_master\_query"  
> }  
> ],  
> "type": "search\_phase\_execution\_exception",  
> "reason": "all shards failed",  
> "phase": "query",  
> "grouped": true,  
> "failed\_shards": [  
> {  
> "shard": 0,  
> "index": "new\_master\_query",  
> "node": "fYXcg-jcSUuvs-ghEWz2CA",  
> "reason": {  
> "type": "query\_shard\_exception",  
> "reason": "failed to create query: {\n "multi\_match" : {\n "query" : "Geosolutions",\n "fields" : [\n "contentid^4.0",\n "object\_summary^2.0",\n "submitted\_for\_name^1.0",\n "title^3.0"\n],\n "type" : "best\_fields",\n "operator" : "OR",\n "slop" : 0,\n "prefix\_length" : 0,\n "max\_expansions" : 50,\n "zero\_terms\_query" : "NONE",\n "auto\_generate\_synonyms\_phrase\_query" : true,\n "fuzzy\_transpositions" : true,\n "boost" : 1.0\n }\n}",  
> "index\_uuid": "yNcq1TcCQWGb0BXGHx2ORg",  
> "index": "new\_master\_query",  
> "caused\_by": {  
> "type": "number\_format\_exception",  
> "reason": "For input string: "Geosolutions""  
> }  
> }  
> }  
> ]  
> },  
> "status": 400  
> }

Kindly guide.  
Regards,  
Priyanka

---

<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:** [June 20, 2019, 12:49pm UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666/2 "2019-06-20T12:49:05Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

Also we can't really tell without seeing the complete error.

---

<div class="post-metadata">

**Author:** ![pyerunka](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@pyerunka](https://discuss.elastic.co/u/pyerunka)\
**Post date:** [June 25, 2019, 3:35am UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666/3 "2019-06-25T03:35:42Z")

</div>

Hello,

Can anyone guide me on this?

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [June 25, 2019, 4:10am UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666/4 "2019-06-25T04:10:08Z")

</div>

Hi,

The problem is here:

```
"caused_by": {
"type": "number_format_exception",
"reason": "For input string: "Geosolutions""
}

```

You try to search for text inside integer mapped fields.  
Can you check your mapping, certainly "contentid" field is integer.

There's similar question here that may help you:

> [@Number format Exception For string type](https://discuss.elastic.co/t/number-format-exception-for-string-type/59175/6):
>
> Hi, did you create the new index before running the reindex? Please follow the example below. This worked fine for me on Elasticsearch 2.4.5 (as your talking about "string" I assumed you are on 2.x; in 5.x "string" type has been split into "text" and "keyword"). Let's start fresh and delete all involved indices for this example: DELETE /old\_books DELETE /new\_books Then create the old index and add a document to it. PUT /old\_books { "mappings": { "author": { "properties": {…

---

<div class="post-metadata">

**Author:** ![pyerunka](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@pyerunka](https://discuss.elastic.co/u/pyerunka)\
**Post date:** [June 25, 2019, 4:52am UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666/5 "2019-06-25T04:52:38Z")

</div>

Hello @gabriel_tessier,

Thanks for reply!!!  
Yes, contentid is an integer. I want to search in that way only. For example, if i searched for "Geosolutions", then it should match my results in all the fields that i have mentioned like contentid,title, object\_summary and submitted\_for\_name. If "Geosolutions" is not matching in contentid, then it should match it in other fields.  
Is there any way to do this? Kindly guide.

Regards,  
Priyanka

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [June 25, 2019, 5:09am UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666/6 "2019-06-25T05:09:49Z")

</div>

Sorry the link was not the correct one:

Here you have better explanation:

> [@Problems with Query\_String and different field types](https://discuss.elastic.co/t/problems-with-query-string-and-different-field-types/4504/2):
>
> Has no one an idea? Or should i report an issue? On 31 Mai, 13:49, maho [mathias.hod...@gmail.com](mailto:mathias.hod...@gmail.com) wrote: Hi, I have an index with two fields: name: description, type: string name: price, type: double If I send following query, I get an NumberFormatException[For input string: "car"] curl -XGET '[http://localhost:9200/sample/products/\_search?pretty'-d](http://localhost:9200/sample/products/_search?pretty'-d) '{ "query" : { "query\_string" : { "fields": ["description", "price"], "query": "car" } } }' Of course, "car" cant be parse…

It's maybe a limitation of elsaticsearch...  
One solution can be to have a string version of "contentid" something like "contentcode" mapped as string, if all your fields are string you'll not have the error and be able to search on all your fields.

---

<div class="post-metadata">

**Author:** ![pyerunka](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@pyerunka](https://discuss.elastic.co/u/pyerunka)\
**Post date:** [June 25, 2019, 9:02am UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666/7 "2019-06-25T09:02:48Z")

</div>

Hello @gabriel_tessier,

Thanks for reply!!!  
I can not mapped contentid as string. i want contentid should always be a number.  
So is there any way to handle this or is this a limitation of ES?

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [June 26, 2019, 1:45am UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666/8 "2019-06-26T01:45:58Z")

</div>

If I come back to the previous message I made link, there's one quote from Clinton\_Gormley which is employee at elastic and certainly know better than me:

> Why are you searching for 'car' against the field 'price'?

How I understand it is for technical reason it's not making sense to search for a string against an integer mapped field.

You have two options one is to use multi-fields keep your field as integer and make your search on contentid.string field. \<--- this one is easy to setup as you can define it only one time in your mapping.

> **[fields | Elasticsearch Guide \[7.2\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.2/multi-fields.html)**

You 'll have a mapping like this:

> {"contentid" : {  
> "match" : "contentid",  
> "mapping" : {  
> "type" : "long",  
> "fields":{  
> "string":{  
> "type": "keyword",  
> "ignore\_above": 20  
> }  
> }  
> }  
> }}

You can use copy\_to if you want to have a separated field that you can use and display.

> **[copy\_to | Elasticsearch Guide \[7.2\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.2/copy-to.html)**

I hope that my explanation are correct and not too much confuse.

---

<div class="post-metadata">

**Author:** ![pyerunka](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@pyerunka](https://discuss.elastic.co/u/pyerunka)\
**Post date:** [June 26, 2019, 5:00am UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666/9 "2019-06-26T05:00:02Z")

</div>

Hello @gabriel_tessier,

Thanks for your reply!!  
How can i use boost option there? i want to apply boost value to each field.

Regards,  
Priyanka

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [June 26, 2019, 5:12am UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666/10 "2019-06-26T05:12:23Z")

</div>

Hi,

If you go with your first query:

> [@pyerunka](#):
>
> GET new\_master\_query/\_search  
> {  
> "query": {  
> "multi\_match": {  
> "query": "Geosolutions",  
> "fields": ["contentid^4", "title^3","object\_summary^2","submitted\_for\_name"] }  
> }  
> }

if you use the solution with multi-fields  
it will change to this:

> "fields": ["contentid.string^4","title^3","object\_summary^2","submitted\_for\_name"] }

there's more detailed explanation about boost in the doc here:

> **[Multi-match query | Elasticsearch Guide \[7.2\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.2/query-dsl-multi-match-query.html#field-boost)**

---

<div class="post-metadata">

**Author:** ![pyerunka](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@pyerunka](https://discuss.elastic.co/u/pyerunka)\
**Post date:** [June 26, 2019, 5:24am UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666/11 "2019-06-26T05:24:34Z")

</div>

Hello @gabriel_tessier,

I have tried but again getting an error:

> GET new\_master\_query/\_search  
> {  
> "contentid" : {  
> "match" : "contentid",  
> "mapping" : {  
> "type" : "number",  
> "fields":["contentid^4", "title^3","object\_summary^2","submitted\_for\_name"]},  
> "string":{  
> "type": "keyword",  
> "ignore\_above": 20  
> }  
> }  
> }  
> }}

> Error:  
> {  
> "error": {  
> "root\_cause": [  
> {  
> "type": "parsing\_exception",  
> "reason": "Unknown key for a START\_OBJECT in [contentid].",  
> "line": 2,  
> "col": 17  
> }  
> ],  
> "type": "parsing\_exception",  
> "reason": "Unknown key for a START\_OBJECT in [contentid].",  
> "line": 2,  
> "col": 17  
> },  
> "status": 400  
> }

Regards,  
Priyanka

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [June 26, 2019, 6:08am UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666/12 "2019-06-26T06:08:00Z")

</div>

Can you please check again:  
[https://www.elastic.co/guide/en/elasticsearch/reference/7.2/multi-fields.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.2/multi-fields.html)

it maybe useful if it's still confuse for you to read about elastic to get the basic concept.  
[https://www.elastic.co/guide/en/elasticsearch/guide/current/getting-started.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/getting-started.html)

about mapping here:  
[https://www.elastic.co/guide/en/elasticsearch/guide/current/mapping-analysis.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/mapping-analysis.html)

You melt mapping and search request.

---

<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 24, 2019, 6:08am UTC](https://discuss.elastic.co/t/error-type-query-shard-exception-while-running-below-query-in-dev-tools/186666/13 "2019-07-24T06:08:01Z")

</div>

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