ElasticSearchIllegalArgumentException No field found for ... in mapping with types

Hello,

I'm having trouble with custom score. I'm not sure what is causing this
type of error. Could be something with mapping?
I'm sure that nesting is fine at this point. Trouble is somehow related
with doc['price'].value

My request:
curl -XGET 'http://localhost:9200/cc_active/page/_search/?pretty=true' -d '
{
query : {
custom_score : {
query:
{bool:
{must: [
{query_string:
{ query: "bilbo*", default_operator: "AND", analyze_wildcard: true, fields:
[ "prior_keywords.lv^5", "keywords.lv^4"] }
}
]
}
},
script : "_score + doc['price'].value"
}
}
}
'

and I get this error:
{
"error" : "SearchPhaseExecutionException[Failed to execute phase
[query_fetch], total failure; shardFailures
{[1MKcC6LWTfCrbMF-jdUq3Q][cc_7][0]: QueryPhaseExecutionException[[cc_7][0]:
query[filtered(custom score ((prior_keywords.lv:bilb*^5.0 |
keywords.lv:bilb*^4.0),function=script[_score + doc[price].value], params
[null]))->cache(_type:page)],from[0],size[10]: Query Failed [Failed to
execute main query]]; nested: CompileException[[Error: No field found for
[org.elasticsearch.index.field.data.ints.IntDocFieldData@32e9c040] in
mapping with types [page]]\n[Near : {... _score + doc[price].value ....}]\n
^\n[Line: 1, Column: 1]]; nested: ElasticSearchIllegalArgumentException[No
field found for
[org.elasticsearch.index.field.data.ints.IntDocFieldData@32e9c040] in
mapping with types [page]
]; }]",
"status" : 500
}

I'm using version 0.19.9.

--

Hiya

I'm having trouble with custom score. I'm not sure what is causing
this type of error. Could be something with mapping?

You correctly suspect a problem with the mapping, but you don't provide
the mapping....

clint

--

Here is simplified version:

curl -XGET 'http://localhost:9200/cc_active/_mapping/?pretty=1'
{
"cc_7" : {
"page" : {
"index_analyzer" : "index_analyzer",
"search_analyzer" : "search_analyzer",
"_all" : {
"enabled" : false
},
"properties" : {
"keywords" : {
"properties" : {
"lv" : {
"type" : "multi_field",
"fields" : {
"lv" : {
"type" : "string",
"analyzer" : "index_analyzer"
},
"precise" : {
"type" : "string",
"analyzer" : "index_analyzer_precise",
"include_in_all" : false
}
}
}
}
},
"prior_keywords" : {
"properties" : {
"lv" : {
"type" : "multi_field",
"fields" : {
"lv" : {
"type" : "string",
"analyzer" : "index_analyzer"
},
"precise" : {
"type" : "string",
"analyzer" : "index_analyzer_precise",
"include_in_all" : false
}
}
}
}
},
"price" : {
"type" : "integer",
"ignore_malformed" : false
},
}
}
}
}

piektdiena, 2012. gada 19. oktobris 13:32:06 UTC+3, Clinton Gormley
rakstīja:

Hiya

I'm having trouble with custom score. I'm not sure what is causing
this type of error. Could be something with mapping?

You correctly suspect a problem with the mapping, but you don't provide
the mapping....

clint

--

On Fri, 2012-10-19 at 03:59 -0700, dzintarsrerihs wrote:

Here is simplified version:

OK - took me a while to find it. Your mapping is fine. Your curl
statement isn't. To highlight the relevant bits:

curl -XGET 'http://localhost:9200/cc_active/page/_search/?pretty=true' -d '
...
script : "_score + doc['price'].value"
...
'

The quotes around 'price' are actually closing the quotes around your request body.

Try this instead:

script : "_score + doc[\u0027price\u0027].value"

\u0027 is a single quote in unicode

clint

--

Thank you for your assistance. Didn't notice that, but yes, this solves the
problem and everything else with scoring calculatio works fine now.
Have a good friday!

Dzintars

piektdiena, 2012. gada 19. oktobris 14:32:00 UTC+3, Clinton Gormley
rakstīja:

On Fri, 2012-10-19 at 03:59 -0700, dzintarsrerihs wrote:

Here is simplified version:

OK - took me a while to find it. Your mapping is fine. Your curl
statement isn't. To highlight the relevant bits:

curl -XGET 'http://localhost:9200/cc_active/page/_search/?pretty=true' -d
'
...
script : "_score + doc['price'].value"
...
'

The quotes around 'price' are actually closing the quotes around your
request body.

Try this instead:

script : "_score + doc[\u0027price\u0027].value"

\u0027 is a single quote in unicode

clint

--

Hi I face same error
"reason": {
"type": "groovy_script_execution_exception",
"reason": "failed to run inline script [(doc['type'].value == 'CZ' ? 'Allowed' : 'Blocked')] using lang [groovy]",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "No field found for [Rtype] in mapping with types []"
}

Tried to implement ternary operator. Can you guide me with this?
Code snippet:
GET /trans/_search
{
"query": {
"match_all": {}
},
"script_fields": {

 "type_1": {
      "script": "(doc['type'].value== 'CZ' ? 'Allowed' : 'Blocked')"
   }

}
}

I tried replacing single quotes with \u0027