Issue 1:
With a multi-level mapping of parent/child relationships on an index, searching with a terms aggregation by _parent on the "middle" child document type (mapped as a child of one type and a parent of another) yields "duplicate" buckets with bogus values for the _parent keys.

Here is an example, with document types my_parent, my_child, and my_grandchild. The query attempts to find, for a given list of parent IDs, the counts of children of those parents, aggregated by color. When my_grandchild is not part of the mapping, the correct expected result buckets are returned. When my_grandchild is included in the mapping, the "duplicate" buckets with bogus _parent keys are also included. The bogus bucket _parent keys are the ids of the my_child documents, though there are no my_grandchild documents, and the my_grandchild document type was not targetted by the query, and would not have matched the _parent values given in the query.

To reproduce, run the following script using the WITH_GRANDCHILD environment variable to dictate whether the my_grandchild mapping should be included or not. For example, run env WITH_GRANDCHILD=true bash script.sh to include the my_grandchild mapping:

#!/usr/bin/env bash

ES_HOST="${ES_HOST:-http://localhost:9200}"
WITH_GRANDCHILD="${WITH_GRANDCHILD:-false}"

echo "env: ES_HOST=${ES_HOST}"
echo " WITH_GRANDCHILD=${WITH_GRANDCHILD}"

function es() {
echo
echo "es ${1} ${2} ${3}"
curl -X"${1}" "${ES_HOST}/${2}" -d "${3}"
echo
}

es DELETE my_index

if [[ X"${WITH_GRANDCHILD}" == X"false" ]]; then
es PUT my_index '{
"mappings": {
"my_parent": {},
"my_child": { "_parent": { "type": "my_parent" } }
}
}'
else
es PUT my_index '{
"mappings": {
"my_parent": {},
"my_child": { "_parent": { "type": "my_parent" } },
"my_grandchild": { "_parent": { "type": "my_child" } }
}
}'
fi

echo
echo "---"

es PUT 'my_index/my_parent/P1' '{ "text": "first parent" }'
es PUT 'my_index/my_parent/P2' '{ "text": "second parent" }'

es PUT 'my_index/my_child/P1_C1?parent=P1' '{ "color": "red" }'
es PUT 'my_index/my_child/P1_C2?parent=P1' '{ "color": "yellow" }'
es PUT 'my_index/my_child/P1_C3?parent=P1' '{ "color": "yellow" }'
es PUT 'my_index/my_child/P2_C1?parent=P2' '{ "color": "green" }'
es PUT 'my_index/my_child/P2_C2?parent=P2' '{ "color": "green" }'
es PUT 'my_index/my_child/P3_C1?parent=P3' '{ "color": "blue" }'

es POST 'my_index/_refresh'

echo
echo "---"

es GET 'my_index/my_child/_search?search_type=count&format=yaml' '{
"query": {
"terms": {
"_parent": [ "P1", "P2" ]
}
},
"aggs": {
"parents": {
"terms": { "field": "_parent" },
"aggs": {
"colors": {
"terms": { "field": "color" }
}
}
}
}
}'

For completeness, here is the expected output of the final query (in YAML format):

---
took: 2
timed_out: false
_shards:
total: 5
successful: 5
failed: 0
hits:
total: 5
max_score: 0.0
hits: []
aggregations:
parents:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: "P1"
doc_count: 3
colors:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: "yellow"
doc_count: 2
- key: "red"
doc_count: 1
- key: "P2"
doc_count: 2
colors:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: "green"
doc_count: 2

And here is the bogus output of the final query (with WITH_GRANDCHILD=true set):

---
took: 2
timed_out: false
_shards:
total: 5
successful: 5
failed: 0
hits:
total: 5
max_score: 0.0
hits: []
aggregations:
parents:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: "P1"
doc_count: 3
colors:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: "yellow"
doc_count: 2
- key: "red"
doc_count: 1
- key: "P2"
doc_count: 2
colors:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: "green"
doc_count: 2
- key: "P1_C1"
doc_count: 1
colors:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: "red"
doc_count: 1
- key: "P1_C2"
doc_count: 1
colors:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: "yellow"
doc_count: 1
- key: "P1_C3"
doc_count: 1
colors:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: "yellow"
doc_count: 1
- key: "P2_C1"
doc_count: 1
colors:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: "green"
doc_count: 1
- key: "P2_C2"
doc_count: 1
colors:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: "green"
doc_count: 1

Issue 2:
I would like to be able to check over the node API if a node has a certain plugin installed or retrieve the list of installed plugins.

For more details see google groups post:

https://groups.google.com/forum/#!topic/elasticsearch/QVRR9Q6VuG0