Facet script issues in production

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) ?

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.
For more options, visit https://groups.google.com/groups/opt_out.

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) ?

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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

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

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) ?

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 <javascript:>.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

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
+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 :slight_smile:

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.
For more options, visit https://groups.google.com/groups/opt_out.

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

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
+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 :slight_smile:

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.
For more options, visit https://groups.google.com/groups/opt_out.

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 :slight_smile:

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 :

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

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
+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 :slight_smile:

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.
For more options, visit https://groups.google.com/groups/opt_out.