I'm using ElasticSearch java client as a Maven dependency:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>1.7.1</version>
</dependency>
I am doing search with multi-index, and I'm getting IndexMissingException
and I want to ignore it using the parameter: 'ignore_unavailable' but I don't know how to use it, and don't found documentation about this.
https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-index.html (link about ignore_unavailable)
I'm creating the search like this:
SearchRequestBuilder srb = ess.getClient()
.prepareSearch(generateIndex(query)) //generateIndex returns a array
.setTypes("mytype")
.setSearchType(SearchType.DFS_QUERY_AND_FETCH)
.setPostFilter(FilterBuilders.rangeFilter("Time")
.from(time1.toInstant(ZoneOffset.UTC))
.to(time2.toInstant(ZoneOffset.UTC))
)
.setFrom(0).setSize(RESULT_MAX).setExplain(true)
//putHeader don't work...
.putHeader("ignore_unavailable", true);
How do I use ignore_unavalilable here?
You need to use setIndicesOptions(IndicesOptions)
- eg.
.prepareSearch(generateIndex(query))
.setIndicesOptions(IndicesOptions.fromOptions(true, false, false, false))
You could also use IndicesOptions.lenientExpandOpen()
instead of calling fromOptions()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With