The generated API clients are a work in progress, you can also find our stable clients on the Algolia documentation.

Skip to main content

Java

Methods targeting an indexName

Prior to the initIndex removal stated in the common breaking changes, all methods previously available at the initIndex level requires the indexName to be sent with the query.

That also mean you need to explicit the type you want to be returned from your queries, when it applies.

import com.algolia.api.SearchClient;
import com.algolia.model.search.*;

SearchClient client = new SearchClient("<YOUR_APP_ID>", "<YOUR_API_KEY>");

client.search(
new SearchMethodParams()
.addRequests(
new SearchForHits()
.setIndexName("<YOUR_INDEX_NAME>")
.setQuery("<YOUR_QUERY>")
)
);