spring-projects / spring-data-elasticsearch

Provide support to increase developer productivity in Java when using Elasticsearch. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-elasticsearch/
Apache License 2.0
2.92k stars 1.33k forks source link

Search across all indices and all types [DATAES-356] #931

Closed spring-projects-issues closed 4 years ago

spring-projects-issues commented 7 years ago

YoungChen opened DATAES-356 and commented

This article says elasticsearch supports Multi-index, Multitype, like:

/_search
Search all types in all indices

Though the following code

new NativeSearchQueryBuilder().withQuery(matchAllQuery()).withTypes("hetro").withIndices(INDEX_1_NAME, INDEX_2_NAME).build()

can search across multiple indices, now I'd like to search across all indices and all types, since I don't know what the indices and types names are.

It seems that I have to specify the indices and types names, because there's a check in the following code in ElasticsearchTemplate:

private SearchRequestBuilder prepareSearch(Query query) {
        Assert.notNull(query.getIndices(), "No index defined for Query");
        Assert.notNull(query.getTypes(), "No type defined for Query");
                ...
}

I'm wondering if spring-data-elasticsearch support searching across all indices and types.


Affects: 2.1 GA (Ingalls)

spring-projects-issues commented 4 years ago

sothawo commented

types aren't supported anymore, and for the index you can use @Document(indexName="*")