I am getting the error pasted in this question and it is true: there isn't Sugestao index. The proper name is sugestao (take a note S versus s).
As far as I know, I can't create a index with upper case. So far so good. The issue is: how can "force" spring-data-elasticsearch to search for sugestao instead of Sugestao since my model is a java class in uppercase? I guess it is picking up uppercase automatically.
In Spring-Data-Elasticsearch-3.2.6 (Elastic version 6.x) I can see find has a clear way to set like
reactiveElasticsearchOperations.find(
query.build(),
Sugestao.class, // this is the model class
"this_is_my_index_name" //here I can write the name of the index with lower case
)
How can I do similar approach in Spring-data-Elasticsearch.4 (Elastic version 7.x) I am trying with search since find is deprecated
Flux<SearchHit<Sugestao>> fluxSearchHits =
reactiveElasticsearchOperations.search(query.build(), Sugestao.class, "sugestao");
And I get
The method search(Query, Class, Class) in the type ReactiveSearchOperations is not applicable for the arguments (NativeSearchQuery, Class, String)
Some related sub-questions are:
it seems in deprecated version of Find I could pass a String and now in search it is expecting a Class. But which class is that to set the index name?
maybe I can set in other spring-data-elasticsearch config the name of the index or set it to use lowercase an then I can search without adding index name.
Flux> fluxSearchHits = reactiveElasticsearchOperations.search(query.build(), Sugestao.class);
I suppose you don't have the @Document
annotation on your entity class?
@Document(indexName="sugestao")
public class Sugestao {
// class stuff
}
Then you can call
Flux<SearchHit<Sugestao>> fluxSearchHits =
reactiveElasticsearchOperations.search(query.build(), Sugestao.class);
If you want to specify the index name explicitly you can use
Flux<SearchHit<Sugestao>> fluxSearchHits =
reactiveElasticsearchOperations.search(query.build(),
Sugestao.class, IndexCoordinates.of("sugestao");
The API documentation for ReactiveSearchOperations
has the different methods documented.