# Facet script issues in production

**URL:** <https://discuss.elastic.co/t/facet-script-issues-in-production/10709>\
**Category:** Elasticsearch\
**Created:** [February 12, 2013, 7:45am UTC](https://discuss.elastic.co/t/facet-script-issues-in-production/10709 "2013-02-12T07:45:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sujoysett](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@sujoysett](https://discuss.elastic.co/u/sujoysett)\
**Post date:** [February 12, 2013, 7:45am UTC](https://discuss.elastic.co/t/facet-script-issues-in-production/10709/1 "2013-02-12T07:45:26Z")

</div>

Hi,

Firstly, apologies for a long post without any gist.  
I am facing quite a lot of issues while doing script term facets on my  
index (nested json structure). But when I tried recreating in a gist,  
everything works fine.

For example, the following query:

{  
"from": 0,  
"size": 0,  
"facets": {  
"facet\_custom": {  
"terms": {  
"script\_field": "_source.?authorJsonMetadata.following +  
"_" + \_source.contentAuthorName",  
"size": 100  
},  
"\_cache": false  
}  
}  
}

gives the following error on production

{"error":"SearchPhaseExecutionException[Failed to execute phase [query],  
total failure; shardFailures  
{[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][4]:  
RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]];  
nested:  
QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][4]:  
query[ConstantScore(NotDeleted(_:_))],from[0],size[0]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error: could not  
access: following; in class: java.util.HashMap]\n[Near : {...  
?authorJsonMetadata.following + \"\_\" + \_source.cont ....}]\n  
^\n[Line: 1, Column: 29]];  
}{[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][1]:  
RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]];  
nested:  
QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][1]:  
query[ConstantScore(NotDeleted(_:_))],from[0],size[0]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error: could not  
access: contentAuthorName; in class:  
org.elasticsearch.search.lookup.SourceLookup]\n[Near : {...  
_source.?authorJsonMetadata.following + \"_\" +  
_source.contentAuthorName ....}]\n  
^\n[Line: 1, Column: 47]];  
}{[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][0]:  
RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]];  
nested:  
QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][0]:  
query[ConstantScore(NotDeleted(:))],from[0],size[0]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error: could not  
access: following; in class: java.util.HashMap]\n[Near : {...  
?authorJsonMetadata.following + \"_\" + \_source.cont ....}]\n  
^\n[Line: 1, Column: 29]];  
}{[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][2]:  
RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]];  
nested:  
QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][2]:  
query[ConstantScore(NotDeleted(_:_))],from[0],size[0]: Query Failed [Failed  
to execute main query]]; nested:  
}{[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][3]:  
RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]];  
nested:  
QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][3]:  
query[ConstantScore(NotDeleted(_:_))],from[0],size[0]: Query Failed [Failed  
to execute main query]]; nested: PropertyAccessException[[Error: could not  
access: following; in class: java.util.HashMap]\n[Near : {...  
\_source.?authorJsonMetadata.fo ....}]\n ^\n[Line: 1, Column:  
1]]; }]","status":500}

But the query works. It worked when I tried locally on a test environment.  
It is something in my production environment that is causing the issues. I  
checked the mappings, all are proper. A sample of the mapping ("1" is type  
of my documents) -

{  
"1": {  
"properties": {  
"authorJsonMetadata": {  
"properties": {  
"favourites": {  
"type": "string",  
"analyzer": "keyword"  
},  
"followers": {  
"type": "string",  
"analyzer": "keyword"  
},  
"following": {  
"type": "string",  
"analyzer": "keyword"  
},  
"likes": {  
"type": "string"  
},  
"listed": {  
"type": "string",  
"analyzer": "keyword"  
}  
}  
},  
"contentAuthorName": {  
"type": "string",  
"analyzer": "keyword"  
}  
}  
}  
}

Null values are probably not the problem. I have tried with data like  
following :

{  
"contentAuthorName": "Any Tickets Now",  
"authorJsonMetadata": null  
}

and

{  
"contentAuthorName": "Any Tickets Now",  
"authorJsonMetadata": {  
"listed": "5",  
"favourites": "0",  
"following": "2002",  
"followers": "1548"  
}  
}

and

{  
"contentAuthorName": "Any Tickets Now",  
"authorJsonMetadata": {  
"listed": "5",  
"favourites": "0",  
"following": null,  
"followers": null  
}  
}

As I told, everything is working fine as I try to reproduce the problem  
locally. In what direction do I need to search in the production  
environment? Any hint from the exception logs?

Also,  
Is there any good documentation on mvel scripts? Other than the official  
site ([http://mvel.codehaus.org/Language+Guide+for+2.0](http://mvel.codehaus.org/Language+Guide+for+2.0)) ?

Thanks,  
-- Sujoy.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [February 12, 2013, 11:46am UTC](https://discuss.elastic.co/t/facet-script-issues-in-production/10709/2 "2013-02-12T11:46:15Z")

</div>

On Mon, 2013-02-11 at 23:45 -0800, Sujoy Sett wrote:

> Hi,
> 
> Firstly, apologies for a long post without any gist.  
> I am facing quite a lot of issues while doing script term facets on my  
> index (nested json structure). But when I tried recreating in a gist,  
> everything works fine.

Is the field really called "?authorJsonMetadata"

clint

> For example, the following query:
> 
> {  
> "from": 0,  
> "size": 0,  
> "facets": {  
> "facet\_custom": {  
> "terms": {  
> "script\_field": "\_source.?authorJsonMetadata.following
> 
> - "\_" + \_source.contentAuthorName",  
> "size": 100  
> },  
> "\_cache": false  
> }  
> }  
> }
> 
> gives the following error on production
> 
> {"error":"SearchPhaseExecutionException[Failed to execute phase  
> [query], total failure; shardFailures  
> {[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][4]:  
> RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]]; nested: QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][4]: query[ConstantScore(NotDeleted(_:_))],from[0],size[0]: Query Failed [Failed to execute main query]]; nested: PropertyAccessException[[Error: could not access: following; in class: java.util.HashMap]\n[Near : {... ?authorJsonMetadata.following + \"\_\" + \_source.cont ....}]\n ^\n[Line: 1, Column: 29]]; }{[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][1]: RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]]; nested: QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][1]: query[ConstantScore(NotDeleted(_:_))],from[0],size[0]: Query Failed [Failed to execute main query]]; nested: PropertyAccessException[[Error: could not access: contentAuthorName; in class: org.elasticsearch.search.lookup.SourceLookup]\n[Near : {... _source.?authorJsonMetadata.following + \"_\" + _source.contentAuthorName ....}]\n ^\n[Line: 1, Column: 47]]; }{[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][0]: RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]]; nested: QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][0]: query[ConstantScore(NotDeleted(:))],from[0],size[0]: Query Failed [Failed to execute main query]]; nested: PropertyAccessException[[Error: could not access: following; in class: java.util.HashMap]\n[Near : {... ?authorJsonMetadata.following + \"_\" + \_source.cont ....}]\n ^\n[Line: 1, Column: 29]]; }{[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][2]: RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]]; nested: QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][2]: query[ConstantScore(NotDeleted(_:_))],from[0],size[0]: Query Failed [Failed to execute main query]]; nested: }{[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][3]: RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]]; nested: QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][3]: query[ConstantScore(NotDeleted(_:_))],from[0],size[0]: Query Failed [Failed to execute main query]]; nested: PropertyAccessException[[Error: could not access: following; in class: java.util.HashMap]\n[Near : {... \_source.?authorJsonMetadata.fo ....}]\n ^\n[Line: 1, Column: 1]]; }]","status":500}
> 
> But the query works. It worked when I tried locally on a test  
> environment. It is something in my production environment that is  
> causing the issues. I checked the mappings, all are proper. A sample  
> of the mapping ("1" is type of my documents) -
> 
> {  
> "1": {  
> "properties": {  
> "authorJsonMetadata": {  
> "properties": {  
> "favourites": {  
> "type": "string",  
> "analyzer": "keyword"  
> },  
> "followers": {  
> "type": "string",  
> "analyzer": "keyword"  
> },  
> "following": {  
> "type": "string",  
> "analyzer": "keyword"  
> },  
> "likes": {  
> "type": "string"  
> },  
> "listed": {  
> "type": "string",  
> "analyzer": "keyword"  
> }  
> }  
> },  
> "contentAuthorName": {  
> "type": "string",  
> "analyzer": "keyword"  
> }  
> }  
> }  
> }
> 
> Null values are probably not the problem. I have tried with data like  
> following :
> 
> {  
> "contentAuthorName": "Any Tickets Now",  
> "authorJsonMetadata": null  
> }
> 
> and
> 
> {  
> "contentAuthorName": "Any Tickets Now",  
> "authorJsonMetadata": {  
> "listed": "5",  
> "favourites": "0",  
> "following": "2002",  
> "followers": "1548"  
> }  
> }
> 
> and
> 
> {  
> "contentAuthorName": "Any Tickets Now",  
> "authorJsonMetadata": {  
> "listed": "5",  
> "favourites": "0",  
> "following": null,  
> "followers": null  
> }  
> }
> 
> As I told, everything is working fine as I try to reproduce the  
> problem locally. In what direction do I need to search in the  
> production environment? Any hint from the exception logs?
> 
> Also,  
> Is there any good documentation on mvel scripts? Other than the  
> official site ([http://mvel.codehaus.org/Language+Guide+for+2.0](http://mvel.codehaus.org/Language+Guide+for+2.0)) ?
> 
> Thanks,  
> -- Sujoy.
> 
> --  
> You received this message because you are subscribed to the Google  
> Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send  
> an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![sujoysett](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@sujoysett](https://discuss.elastic.co/u/sujoysett)\
**Post date:** [February 12, 2013, 12:35pm UTC](https://discuss.elastic.co/t/facet-script-issues-in-production/10709/3 "2013-02-12T12:35:17Z")

</div>

Hi Clint,

The field is called authorJsonMetadata only (without the question mark).  
The question mark is for a null check, something called Null-Safe Bean  
Navigation, as per documentation  
([http://mvel.codehaus.org/MVEL+2.0+Property+Navigation](http://mvel.codehaus.org/MVEL+2.0+Property+Navigation)).

Thanks,  
-- Sujoy.

On Tuesday, February 12, 2013 5:16:15 PM UTC+5:30, Clinton Gormley wrote:

> On Mon, 2013-02-11 at 23:45 -0800, Sujoy Sett wrote:
> 
> > Hi,
> > 
> > Firstly, apologies for a long post without any gist.  
> > I am facing quite a lot of issues while doing script term facets on my  
> > index (nested json structure). But when I tried recreating in a gist,  
> > everything works fine.
> 
> Is the field really called "?authorJsonMetadata"
> 
> clint
> 
> > For example, the following query:
> > 
> > {  
> > "from": 0,  
> > "size": 0,  
> > "facets": {  
> > "facet\_custom": {  
> > "terms": {  
> > "script\_field": "\_source.?authorJsonMetadata.following
> > 
> > - "\_" + \_source.contentAuthorName",  
> > "size": 100  
> > },  
> > "\_cache": false  
> > }  
> > }  
> > }
> > 
> > gives the following error on production
> > 
> > {"error":"SearchPhaseExecutionException[Failed to execute phase  
> > [query], total failure; shardFailures  
> > {[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][4]:
> 
> RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]];  
> nested:  
> QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][4]:  
> query[ConstantScore(NotDeleted(_:_))],from[0],size[0]: Query Failed [Failed  
> to execute main query]]; nested: PropertyAccessException[[Error: could not  
> access: following; in class: java.util.HashMap]\n[Near : {...  
> ?authorJsonMetadata.following + \"\_\" + \_source.cont ....}]\n  
> ^\n[Line: 1, Column: 29]];  
> }{[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][1]:  
> RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]];  
> nested:  
> QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][1]:  
> query[ConstantScore(NotDeleted(_:_))],from[0],size[0]: Query Failed [Failed  
> to execute main query]]; nested: PropertyAccessException[[Error: could not  
> access: contentAuthorName; in class:  
> org.elasticsearch.search.lookup.SourceLookup]\n[Near : {...  
> _source.?authorJsonMetadata.following + \"_\" +  
> _source.contentAuthorName ....}]\n  
> ^\n[Line: 1, Column: 47]];  
> }{[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][0]:  
> RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]];  
> nested:  
> QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][0]:  
> query[ConstantScore(NotDeleted(:))],from[0],size[0]: Query Failed [Failed  
> to execute main query]]; nested: PropertyAccessException[[Error: could not  
> access: following; in class: java.util.HashMap]\n[Near : {...  
> ?authorJsonMetadata.following + \"_\" + \_source.cont ....}]\n  
> ^\n[Line: 1, Column: 29]];  
> }{[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][2]:  
> RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]];  
> nested:  
> QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][2]:  
> query[ConstantScore(NotDeleted(_:_))],from[0],size[0]: Query Failed [Failed  
> to execute main query]]; nested:  
> }{[Z2lBIB8NRPKnIkgXgK9cPg][lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][3]:  
> RemoteTransportException[[dmz14\_data\_node][inet[/192.168.150.14:9301]][search/phase/query]];  
> nested:  
> QueryPhaseExecutionException[[lp-192.168.150.15-5444-lp\_test-lp\_4\_5-1][3]:  
> query[ConstantScore(NotDeleted(_:_))],from[0],size[0]: Query Failed [Failed  
> to execute main query]]; nested: PropertyAccessException[[Error: could not  
> access: following; in class: java.util.HashMap]\n[Near : {...  
> \_source.?authorJsonMetadata.fo ....}]\n ^\n[Line: 1, Column:  
> 1]]; }]","status":500}
> 
> > But the query works. It worked when I tried locally on a test  
> > environment. It is something in my production environment that is  
> > causing the issues. I checked the mappings, all are proper. A sample  
> > of the mapping ("1" is type of my documents) -
> > 
> > {  
> > "1": {  
> > "properties": {  
> > "authorJsonMetadata": {  
> > "properties": {  
> > "favourites": {  
> > "type": "string",  
> > "analyzer": "keyword"  
> > },  
> > "followers": {  
> > "type": "string",  
> > "analyzer": "keyword"  
> > },  
> > "following": {  
> > "type": "string",  
> > "analyzer": "keyword"  
> > },  
> > "likes": {  
> > "type": "string"  
> > },  
> > "listed": {  
> > "type": "string",  
> > "analyzer": "keyword"  
> > }  
> > }  
> > },  
> > "contentAuthorName": {  
> > "type": "string",  
> > "analyzer": "keyword"  
> > }  
> > }  
> > }  
> > }
> > 
> > Null values are probably not the problem. I have tried with data like  
> > following :
> > 
> > {  
> > "contentAuthorName": "Any Tickets Now",  
> > "authorJsonMetadata": null  
> > }
> > 
> > and
> > 
> > {  
> > "contentAuthorName": "Any Tickets Now",  
> > "authorJsonMetadata": {  
> > "listed": "5",  
> > "favourites": "0",  
> > "following": "2002",  
> > "followers": "1548"  
> > }  
> > }
> > 
> > and
> > 
> > {  
> > "contentAuthorName": "Any Tickets Now",  
> > "authorJsonMetadata": {  
> > "listed": "5",  
> > "favourites": "0",  
> > "following": null,  
> > "followers": null  
> > }  
> > }
> > 
> > As I told, everything is working fine as I try to reproduce the  
> > problem locally. In what direction do I need to search in the  
> > production environment? Any hint from the exception logs?
> > 
> > Also,  
> > Is there any good documentation on mvel scripts? Other than the  
> > official site ([http://mvel.codehaus.org/Language+Guide+for+2.0](http://mvel.codehaus.org/Language+Guide+for+2.0)) ?
> > 
> > Thanks,  
> > -- Sujoy.
> > 
> > --  
> > You received this message because you are subscribed to the Google  
> > Groups "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send  
> > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [February 12, 2013, 1:02pm UTC](https://discuss.elastic.co/t/facet-script-issues-in-production/10709/4 "2013-02-12T13:02:41Z")

</div>

On Tue, 2013-02-12 at 04:35 -0800, Sujoy Sett wrote:

> Hi Clint,
> 
> The field is called authorJsonMetadata only (without the question  
> mark).  
> The question mark is for a null check, something called Null-Safe Bean  
> Navigation, as per documentation ([http://mvel.codehaus.org/MVEL+2.0](http://mvel.codehaus.org/MVEL+2.0)  
> +Property+Navigation).

ah ok - wasn't aware of that. Just tried it out and found that it works,  
as it does for you in dev 🙂

No idea what the problem is, but you sure that the script is being  
escaped correctly in the JSON? \</reaching\_for\_straws\>

clint

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![sujoysett](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@sujoysett](https://discuss.elastic.co/u/sujoysett)\
**Post date:** [February 12, 2013, 1:32pm UTC](https://discuss.elastic.co/t/facet-script-issues-in-production/10709/5 "2013-02-12T13:32:43Z")

</div>

Not sure why string escaping would fail, but I tried via curl as well as  
firefox poster. Same results.  
Had similarly suspected newlines as culprit, but no hope there too.  
☹

Thanks,  
-- Sujoy.

On Tuesday, February 12, 2013 6:32:41 PM UTC+5:30, Clinton Gormley wrote:

> On Tue, 2013-02-12 at 04:35 -0800, Sujoy Sett wrote:
> 
> > Hi Clint,
> > 
> > The field is called authorJsonMetadata only (without the question  
> > mark).  
> > The question mark is for a null check, something called Null-Safe Bean  
> > Navigation, as per documentation ([http://mvel.codehaus.org/MVEL+2.0](http://mvel.codehaus.org/MVEL+2.0)  
> > +Property+Navigation).
> 
> ah ok - wasn't aware of that. Just tried it out and found that it works,  
> as it does for you in dev 🙂
> 
> No idea what the problem is, but you sure that the script is being  
> escaped correctly in the JSON? \</reaching\_for\_straws\>
> 
> clint

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Lucien\_Boix](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lucien_boix/32/1969_2.png) [@Lucien\_Boix](https://discuss.elastic.co/u/Lucien_Boix)\
**Post date:** [November 19, 2013, 3:25pm UTC](https://discuss.elastic.co/t/facet-script-issues-in-production/10709/6 "2013-11-19T15:25:49Z")

</div>

Hi Sujoy,

I faced the same situation with my team : \_source's use worked well in our  
script in local, preproduction, except in production.

Try to "shield" \_source attributes' access like this :  
"script\_field": "if (\_source.authorJsonMetadata != null &&  
\_source.authorJsonMetadata.following != null && \_source.contentAuthorName  
!= null) {_source.?authorJsonMetadata.following + "_" +  
\_source.contentAuthorName"}

And let me know the result please 🙂

To what I undestood, the script will be run for each document and a null  
(given to the data : not all documents will be 100% filled) can't be  
handled using \_source.  
The "?" operator is a good idea but il actually return null in some cases  
and we don't want this.

Furthermore :

- if your mapping means a document have 1 authorJsonMetadata and 1contentAuthorName,  
you should use the doc['field1(.field2.etc)'] accessor :  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-script-fields.html)
- if you plan dealing with nested objects _inside_ a script, maybe I can  
help you here :  
[Elasticsearch access nested data inside script filter (avoid PropertyAccessException using \_source) - Stack Overflow](http://stackoverflow.com/questions/19845615/elasticsearch-access-nested-data-inside-script-filter)

Regards!

Lucien

Le mardi 12 février 2013 08:32:43 UTC-5, Sujoy Sett a écrit :

> Not sure why string escaping would fail, but I tried via curl as well as  
> firefox poster. Same results.  
> Had similarly suspected newlines as culprit, but no hope there too.  
> ☹
> 
> Thanks,  
> -- Sujoy.
> 
> On Tuesday, February 12, 2013 6:32:41 PM UTC+5:30, Clinton Gormley wrote:
> 
> > On Tue, 2013-02-12 at 04:35 -0800, Sujoy Sett wrote:
> > 
> > > Hi Clint,
> > > 
> > > The field is called authorJsonMetadata only (without the question  
> > > mark).  
> > > The question mark is for a null check, something called Null-Safe Bean  
> > > Navigation, as per documentation ([http://mvel.codehaus.org/MVEL+2.0](http://mvel.codehaus.org/MVEL+2.0)  
> > > +Property+Navigation).
> > 
> > ah ok - wasn't aware of that. Just tried it out and found that it works,  
> > as it does for you in dev 🙂
> > 
> > No idea what the problem is, but you sure that the script is being  
> > escaped correctly in the JSON? \</reaching\_for\_straws\>
> > 
> > clint

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:06am UTC](https://discuss.elastic.co/t/facet-script-issues-in-production/10709/7 "2017-07-06T02:06:13Z")

</div>


