# Has\_parent queries across multiple indices where types may not exist

**URL:** <https://discuss.elastic.co/t/has-parent-queries-across-multiple-indices-where-types-may-not-exist/44582>\
**Category:** Elasticsearch\
**Created:** [March 16, 2016, 3:44pm UTC](https://discuss.elastic.co/t/has-parent-queries-across-multiple-indices-where-types-may-not-exist/44582 "2016-03-16T15:44:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjmc7](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@sjmc7](https://discuss.elastic.co/u/sjmc7)\
**Post date:** [March 16, 2016, 3:44pm UTC](https://discuss.elastic.co/t/has-parent-queries-across-multiple-indices-where-types-may-not-exist/44582/1 "2016-03-16T15:44:26Z")

</div>

Hi,

If I create two indices, index\_a and index\_b:

```
$ curl localhost:9200/index_a -XPUT -d'{"mappings": {"parent-type": {}, "child-type": {"_parent": {"type": "parent-type"}}}}'

$ curl localhost:9200/index_b -XPUT -d'{"mappings": {"some-type": {}}}'

```

The following query gives an error:

```
$ curl localhost:9200/index_a,index_b/_search -d'{"query": {"has_parent": {"type": "parent-type", "query": {"match_all": {}}}}}'

{"took":172,"timed_out":false,"_shards":{"total":2,"successful":1,"failed":1,"failures":[{"index":"index_b","shard":0,"status":400,"reason":"SearchParseException[[index_b][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\": {\"has_parent\": {\"type\": \"parent-type\", \"query\": {\"match_all\": {}}}}}]]]; nested: QueryParsingException[[index_b] [has_parent] query configured 'parent_type' [parent-type] is not a valid type]; "}]},"hits":{"total":0,"max_score":null,"hits":[]}}

```

This isn't entirely unexpected, but is there any way to have elasticsearch treat the missing type as a negative result rather than a failure?

My larger use case is that index\_a and index\_b have different document types and mappings (though some fields are common to all types) but we want to run queries across them both (and I was hoping to be able to do it with "indices" filters to target queries only where they made sense). multisearch might be an answer, but isn't quite the same since we'd need to merge the results (and size/sorting applies to each targeted search individually).

Thanks!

Steve

---

<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 5, 2017, 11:07pm UTC](https://discuss.elastic.co/t/has-parent-queries-across-multiple-indices-where-types-may-not-exist/44582/2 "2017-07-05T23:07:53Z")

</div>


