Error "type": "query_shard_exception" while running below query in dev tools

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

Please format your code, logs or configuration files using </> icon as explained in this guide 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:

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.

Hello,

Can anyone guide me on this?

Thanks,
Priyanka

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:

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

Sorry the link was not the correct one:

Here you have better explanation:

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.

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

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.

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.
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.

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

Hi,

If you go with your first query:

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:
https://www.elastic.co/guide/en/elasticsearch/reference/7.2/query-dsl-multi-match-query.html#field-boost

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

Can you please check again:
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

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

You melt mapping and search request.

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