Using script filters in both the parent and the child filters fails

I've encountered a weird problem that I hope someone has seen before, and
can provide a resolution for.

I'm running Elasticsearch 1.0 downloaded as an RPM and installed on a
cluster of two RedHat nodes. Five shards with one replica each is
configured.

Unfortunately, I could not reproduce the problem with test data (yet), even
though I tried it for hours. I'm posting my simplified setup with the hope
that it helps.

create the index

curl -XPUT http://localhost:9200/test_script/

add mapping for parent type

curl -XPUT http://localhost:9200/test_script/my_parent/_mapping -d '
{
"my_parent": {
"properties": {
"name": {"type": "string"}
}
}
}'

add mapping for child type

curl -XPUT http://localhost:9200/test_script/my_child/_mapping -d '
{
"my_child": {
"_parent": {"type": "my_parent"},
"properties": {
"value": {"type": "long"}
}
}
}'

index some records

curl -XPUT http://localhost:9200/test_script/my_parent/1 -d '{"name":
"Parent"}'
curl -XPUT http://localhost:9200/test_script/my_parent/2 -d '{"name":
"ParentTwo"}'
curl -XPUT http://localhost:9200/test_script/my_parent/3 -d '{"name":
"ParentThree"}'
curl -XPUT http://localhost:9200/test_script/my_child/abc?parent=1 -d
'{"value": 1234567}'

When I execute the following search (on my real index)

curl -XGET http://localhost:9200/test_script/my_parent/_search?pretty=true
-d '
{
"query": {
"filtered": {
"filter": {
"bool": {
"must_not": {
"has_child": {
"type": "my_child",
"filter": {
"script": {
"script":
"doc["my_child.value"].value != 1234567"
}
}
}
},
"must": {
"script": {
"script":
"doc["my_parent.name"].value.equals("parent")"
}
}
}
}
}
}
}'

I get partial results because one of the shards fails with this error

"_shards" : {
"total" : 5,
"successful" : 4,
"failed" : 1,
"failures" : [ {
"index" : "test_script",
"shard" : 4,
"status" : 500,
"reason" :
"RemoteTransportException[[host-2][inet[/192.168.0.2:9300]][search/phase/query]];
nested: QueryPhaseExecutionException[[test_script][4]:
query[filtered(ConstantScore(BooleanFilter(-CustomQueryWrappingFilter(child_filter[my_child/my_parent](filtered(ConstantScore(ScriptFilter(vid=(String)doc["my_child."].value;
doc["my_child.value"].value !=
1234567;)))->cache(_type:my_child))))))->cache(_type:my_parent)],from[0],size[10]:
Query Failed [Failed to execute main query]]; nested:
PropertyAccessException[[Error: could not access: value; in class:
org.elasticsearch.index.fielddata.ScriptDocValues$Empty]\n[Near : {...
value ....}]\n ^\n[Line: 1, Column: 1]]; "

All fields are dense (i.e. populated in every parent or child record), so
the field and the value should be available.

It might be helpful to note that the exception always occurs on the other
node and not on the one my http request targeted.

I never get an error, but receive the correct results, if I change the
query to something like this

curl -XGET http://localhost:9200/test_script/my_parent/_search?pretty=true
-d '
{
"query": {
"filtered": {
"filter": {
"bool": {
"must_not": {
"has_child": {
"type": "my_child",
"filter": {
"script": {
"script":
"doc["my_child.value"].value != 1234567"
}
}
}
},
"must": {
* "term": {"my_parent.name": "parent"}*
}
}
}
}
}
}'

I appreciate any help you can provide.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/7768222d-a7d7-41e8-bfc9-5dbe0ad13a8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Update: I've tried to clear the cache, to refresh the index, closing and
reopening the index, no joy. Then everything started to work automagically
after a while (tens of minutes later). The index itself has a total of 620
docs.

On Wednesday, April 9, 2014 1:45:32 PM UTC-5, Jozsef Szalay wrote:

I've encountered a weird problem that I hope someone has seen before, and
can provide a resolution for.

I'm running Elasticsearch 1.0 downloaded as an RPM and installed on a
cluster of two RedHat nodes. Five shards with one replica each is
configured.

Unfortunately, I could not reproduce the problem with test data (yet),
even though I tried it for hours. I'm posting my simplified setup with the
hope that it helps.

create the index

curl -XPUT http://localhost:9200/test_script/

add mapping for parent type

curl -XPUT http://localhost:9200/test_script/my_parent/_mapping -d '
{
"my_parent": {
"properties": {
"name": {"type": "string"}
}
}
}'

add mapping for child type

curl -XPUT http://localhost:9200/test_script/my_child/_mapping -d '
{
"my_child": {
"_parent": {"type": "my_parent"},
"properties": {
"value": {"type": "long"}
}
}
}'

index some records

curl -XPUT http://localhost:9200/test_script/my_parent/1 -d '{"name":
"Parent"}'
curl -XPUT http://localhost:9200/test_script/my_parent/2 -d '{"name":
"ParentTwo"}'
curl -XPUT http://localhost:9200/test_script/my_parent/3 -d '{"name":
"ParentThree"}'
curl -XPUT http://localhost:9200/test_script/my_child/abc?parent=1 -d
'{"value": 1234567}'

When I execute the following search (on my real index)

curl -XGET http://localhost:9200/test_script/my_parent/_search?pretty=true-d '
{
"query": {
"filtered": {
"filter": {
"bool": {
"must_not": {
"has_child": {
"type": "my_child",
"filter": {
"script": {
"script":
"doc["my_child.value"].value != 1234567"
}
}
}
},
"must": {
"script": {
"script": "doc["my_parent.name
"].value.equals("parent")"
}
}
}
}
}
}
}'

I get partial results because one of the shards fails with this error

"_shards" : {
"total" : 5,
"successful" : 4,
"failed" : 1,
"failures" : [ {
"index" : "test_script",
"shard" : 4,
"status" : 500,
"reason" :
"RemoteTransportException[[host-2][inet[/192.168.0.2:9300]][search/phase/query]];
nested: QueryPhaseExecutionException[[test_script][4]:
query[filtered(ConstantScore(BooleanFilter(-CustomQueryWrappingFilter(child_filter[my_child/my_parent](filtered(ConstantScore(ScriptFilter(vid=(String)doc["my_child."].value;
doc["my_child.value"].value !=
1234567;)))->cache(_type:my_child))))))->cache(_type:my_parent)],from[0],size[10]:
Query Failed [Failed to execute main query]]; nested:
PropertyAccessException[[Error: could not access: value; in class:
org.elasticsearch.index.fielddata.ScriptDocValues$Empty]\n[Near : {...
value ....}]\n ^\n[Line: 1, Column: 1]]; "

All fields are dense (i.e. populated in every parent or child record), so
the field and the value should be available.

It might be helpful to note that the exception always occurs on the other
node and not on the one my http request targeted.

I never get an error, but receive the correct results, if I change the
query to something like this

curl -XGET http://localhost:9200/test_script/my_parent/_search?pretty=true-d '
{
"query": {
"filtered": {
"filter": {
"bool": {
"must_not": {
"has_child": {
"type": "my_child",
"filter": {
"script": {
"script":
"doc["my_child.value"].value != 1234567"
}
}
}
},
"must": {
* "term": {"my_parent.name
http://my_parent.name": "parent"}*
}
}
}
}
}
}'

I appreciate any help you can provide.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/83b54a47-0ccb-424f-99ea-1a166b2ed739%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.