Skip to main content

Migration guide

warning

The amount of changes in this new version is significant. If you were using a version older than v4, please also read this migration guide.

You should thoroughly test your application before deploying to production.

This document lists every known breaking change, not all of them may affect your application.

Common breaking changes

The changes below are effective on all of the API clients.

initIndex


Methods previously available at the initIndex level are now available at the root level of the API client.

The indexName parameter is now required when calling those methods.

java
import com.algolia.model.search.*;
SearchClient client = new SearchClient(
"<YOUR_APP_ID>",
"<YOUR_API_KEY>"
);
client.search(
new SearchMethodParams()
.addRequests(SearchQuery.ofSearchForHits(
new SearchForHits()
.setIndexName("<YOUR_INDEX_NAME>")
.setQuery("<YOUR_QUERY>")
.addAttributesToRetrieve("firstname")
.addAttributesToRetrieve("lastname")
.setHitsPerPage(50)
)
)
);
java
import com.algolia.model.search.*;
SearchClient client = new SearchClient(
"<YOUR_APP_ID>",
"<YOUR_API_KEY>"
);
client.search(
new SearchMethodParams()
.addRequests(SearchQuery.ofSearchForHits(
new SearchForHits()
.setIndexName("<YOUR_INDEX_NAME>")
.setQuery("<YOUR_QUERY>")
.addAttributesToRetrieve("firstname")
.addAttributesToRetrieve("lastname")
.setHitsPerPage(50)
)
)
);

wait


The chainable wait method that was available on a few methods has been replaced with an helper called waitForTask.

You can now optionally configure how the wait logic behaves by passing the taskID returned when calling the Algolia API.

Read the dedicated guide

java
import com.algolia.model.search.*;
Map<String, Object> body = new HashMap<>();
body.put("title", "My Algolia Object");
SaveObjectResponse response = client.saveObject(
"<YOUR_INDEX_NAME>",
body
);
// Poll the task status with defaults values
client.waitForTask("<YOUR_INDEX_NAME>", response.getTaskID());
java
import com.algolia.model.search.*;
Map<String, Object> body = new HashMap<>();
body.put("title", "My Algolia Object");
SaveObjectResponse response = client.saveObject(
"<YOUR_INDEX_NAME>",
body
);
// Poll the task status with defaults values
client.waitForTask("<YOUR_INDEX_NAME>", response.getTaskID());

moveIndex/copyIndex


The operationIndex allows you to either copy or move a source index to a destination index within the same Algolia application.

You can also decide what scope of the source index should be copied, read more on our dedicated guide.

java
import com.algolia.model.search.*;
UpdatedAtResponse response = client.operationIndex(
"<SOURCE_INDEX_NAME>",
new OperationIndexParams()
.setDestination("<DESTINATION_INDEX_NAME>")
.setOperation(OperationType.COPY) // or MOVE
);
// Poll the task status until it's done
client.waitForTask("<SOURCE_INDEX_NAME>", response.getTaskID());
java
import com.algolia.model.search.*;
UpdatedAtResponse response = client.operationIndex(
"<SOURCE_INDEX_NAME>",
new OperationIndexParams()
.setDestination("<DESTINATION_INDEX_NAME>")
.setOperation(OperationType.COPY) // or MOVE
);
// Poll the task status until it's done
client.waitForTask("<SOURCE_INDEX_NAME>", response.getTaskID());

Client's specific breaking changes

You can find specific client breaking changes in their own section: