Hi all,
recently I came across the problem, described in this post:
Delete one child type mapping, affected other children queries
Unfortunately, there were no replies or comments there. That is why I'll describe the problem once more.
I used the examples provided in the article:
Fun With Elasticsearch's Children and Nested Documents
I've created an "authors" index and added 2 documents to the "bare_author" type, with the help of:
curl -XPUT localhost:9200/authors/bare_author/1 -d'{"name": "Multi G. Enre"}'
curl -XPUT localhost:9200/authors/bare_author/2 -d'{"name": "Alastair Reynolds"}'
Then specified the parent-child relation:
curl -XPOST localhost:9200/authors/book/_mapping -d $'{\n "book":{\n "_parent": {"type": "bare_author"}\n }\n}'
Added 3 documents to the "book" mapping:
curl -XPOST localhost:9200/authors/book/1?parent=2 -d $'{\n "name": "Revelation Space",\n "genre": "scifi",\n "publisher": "penguin"\n}'
curl -XPOST localhost:9200/authors/book/2?parent=1 -d $'{\n "name": "Guns and lasers",\n "genre": "scifi",\n "publisher": "orbit"\n}'
curl -XPOST localhost:9200/authors/book/3?parent=1 -d $'{\n "name": "Dead in the night",\n "genre": "thriller",\n "publisher": "penguin"\n}'
Specified another parent-child relation:
curl -XPOST localhost:9200/authors/magazine/_mapping -d $'{\n "magazine":{\n "_parent": {"type": "bare_author"}\n }\n}'
Added 2 documents to the second type:
curl -XPOST localhost:9200/authors/magazine/1?parent=1 -d $'{\n "name": "Fun with Elasticsearch",\n "genre": "blogging",\n "article": "Parent and Child"\n}'
curl -XPOST localhost:9200/authors/magazine/2?parent=2 -d $'{\n "name": "You Know, for Search",\n "genre": "analytic",\n "article": "Managing Relations"\n}'
Up to this moment all goes well. I'm able to query both children types.
Used this query (via elasticsearch _plugin/head):
http://localhost:9200/authors/book/
_search
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": {
"has_parent": {
"query": {
"ids": {
"type": "bare_author",
"values": [
"2"
]
}
},
"parent_type": "bare_author"
}
}
}
}
}
},
"explain": false,
"fields": [
"_parent",
"_source"
]
}
to find a book of the author with id=2.
If I now delete the "magazine" type:
curl -XDELETE localhost:9200/authors/magazine
I'm not able to make any other child queries. Even the one given above, results in: 3 shards return no matches, 2 shards return:
"status": 500,
"reason": "QueryPhaseExecutionException[[authors][2]: query[filtered(ConstantScore(BooleanFilter(+CustomQueryWrappingFilter(parent_filter[bare_author](filtered(ConstantScore(_uid:bare_author#2))->cache(_type:bare_author))))))->cache(_type:book)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: RuntimeException[java.lang.NullPointerException]; nested: NullPointerException; "
Like the author of the previous discussion mentioned, restarting the Elasticsearch helps.
Would appreciate any help, ideas, experience.
Thanks in advance!