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

**URL:** https://discuss.elastic.co/t/elasticsearchillegalargumentexception-no-field-found-for-in-mapping-with-types/9420
**Category:** Elasticsearch
**Created:** [October 19, 2012, 9:53am UTC](https://discuss.elastic.co/t/elasticsearchillegalargumentexception-no-field-found-for-in-mapping-with-types/9420 "2012-10-19T09:53:41Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![dzintarsrerihs](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@dzintarsrerihs](https://discuss.elastic.co/u/dzintarsrerihs)
#### Post date: [October 19, 2012, 9:53am UTC](https://discuss.elastic.co/t/elasticsearchillegalargumentexception-no-field-found-for-in-mapping-with-types/9420/1 "2012-10-19T09:53:41Z")

</div>

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

--

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [October 19, 2012, 10:31am UTC](https://discuss.elastic.co/t/elasticsearchillegalargumentexception-no-field-found-for-in-mapping-with-types/9420/2 "2012-10-19T10:31:54Z")

</div>

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

--

---

<div class="post-metadata">

### Author: ![dzintarsrerihs](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@dzintarsrerihs](https://discuss.elastic.co/u/dzintarsrerihs)
#### Post date: [October 19, 2012, 10:59am UTC](https://discuss.elastic.co/t/elasticsearchillegalargumentexception-no-field-found-for-in-mapping-with-types/9420/3 "2012-10-19T10:59:09Z")

</div>

Here is simplified version:

curl -XGET '[http://localhost:9200/cc\_active/\_mapping/?pretty=1](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

--

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [October 19, 2012, 11:31am UTC](https://discuss.elastic.co/t/elasticsearchillegalargumentexception-no-field-found-for-in-mapping-with-types/9420/4 "2012-10-19T11:31:49Z")

</div>

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](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

--

---

<div class="post-metadata">

### Author: ![dzintarsrerihs](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@dzintarsrerihs](https://discuss.elastic.co/u/dzintarsrerihs)
#### Post date: [October 19, 2012, 11:40am UTC](https://discuss.elastic.co/t/elasticsearchillegalargumentexception-no-field-found-for-in-mapping-with-types/9420/5 "2012-10-19T11:40:36Z")

</div>

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](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

--

---

<div class="post-metadata">

### Author: ![nivetha](https://avatars.discourse-cdn.com/v4/letter/n/54ee81/32.png) [@nivetha](https://discuss.elastic.co/u/nivetha)
#### Post date: [January 11, 2016, 7:45am UTC](https://discuss.elastic.co/t/elasticsearchillegalargumentexception-no-field-found-for-in-mapping-with-types/9420/6 "2016-01-11T07:45:48Z")

</div>

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

---

<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 5, 2017, 11:25pm UTC](https://discuss.elastic.co/t/elasticsearchillegalargumentexception-no-field-found-for-in-mapping-with-types/9420/7 "2017-07-05T23:25:29Z")

</div>


