DefaultSearchClient not found in Algolia playground example

I am intending to migrate my MySQL records into Algolia. My application is using a Java Hibernate Backend with a VueJS frontend. I am trying to follow this search API guide for Java to allow my application to push data from the Java backend. Following the playground examples here.

I can’t seem to import the DefaultSearchClient even after importing the right dependencies as said in the starting guide. This is the pom.xml source code and I am not using any other classes other than the 5 given in the url, what could I be missing here?

Here is my pom.xml and DefaultClientExample.java file for reference, tell me if more information is required.

Here is my pom.xml and DefaultClientExample.java file for reference, tell me if more information is required.

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>NewProject</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.algolia</groupId>
            <artifactId>algoliasearch-core</artifactId>
            <version>LATEST</version>
        </dependency>
        <dependency>
            <groupId>com.algolia</groupId>
            <artifactId>algoliasearch-java-net</artifactId>
            <version>LATEST</version>
        </dependency>
    </dependencies>


</project>

DefaultSearchClient.java

import com.algolia.search.*;
import com.algolia.search.models.indexing.BatchIndexingResponse;
import com.algolia.search.models.indexing.Query;
import com.algolia.search.models.indexing.SearchResult;
import com.algolia.search.models.settings.IndexSettings;
import com.algolia.search.models.settings.SetSettingsResponse;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException; 

public class DefaultClientExample {

  public static void run() throws ExecutionException, InterruptedException, IOException {
    // Create a SearchClient (it's a Closeable, so you can leverage the try-with-resources
    // construction
    // to let the JVM close underlying resources when appropriate)
    try (SearchClient searchClient =
        DefaultSearchClient.create(Main.ALGOLIA_APPLICATION_ID_1, Main.ALGOLIA_API_KEY_1)) { //DefaultSearchClient not found

      // Init an index
      SearchIndex<Employee> index =
          searchClient.initIndex("employees_" + System.getProperty("user.name"), Employee.class);

      List<Employee> employees = Employee.hireEmployees();
      CompletableFuture<BatchIndexingResponse> saveObjectsFuture =
          index.saveObjectsAsync(employees, true);

      // Typed index
      IndexSettings settings =
          new IndexSettings()
              .setAttributesForFaceting(Collections.singletonList("searchable(company)"));

      // Typed request/response
      CompletableFuture<SetSettingsResponse> setSettingsFuture = index.setSettingsAsync(settings);

      // Calling get() is blocking on the future to be completed and waitTask is performing Algolia
      // wait operations
      saveObjectsFuture.get().waitTask();
      setSettingsFuture.get().waitTask();

      // Performing multiple typed search asynchronously
      CompletableFuture<SearchResult<Employee>> searchAlgoliaFuture =
          index.searchAsync(new Query("algolia"));

      SearchResult<Employee> search = index.search(new Query("algolia"));

      CompletableFuture<SearchResult<Employee>> searchAppleFuture =
          index.searchAsync(new Query("apple"));

      CompletableFuture<SearchResult<Employee>> searchAmazonFuture =
          index.searchAsync(new Query("amazon"));

      CompletableFuture.allOf(searchAlgoliaFuture, searchAppleFuture, searchAmazonFuture).join();

      System.out.println("Default client :" + search.getHits().get(0).getName());
      System.out.println("Default client :" + searchAlgoliaFuture.get().getHits().get(0).getName());
      System.out.println("Default client :" + searchAppleFuture.get().getHits().get(0).getName());
      System.out.println("Default client :" + searchAmazonFuture.get().getHits().get(0).getName());
    }
  }
}

Hello!

I see that you are using the algoliasearch-java-net module. Unfortunately, this module doesn’t implement the DefaultSearchClient as it’s an advanced module for Java11 users willing to not have the dependency on the DefaltSearchClient we provide which is based on Apache.

Here is a code snippet on how to use the java-net package:

SearchConfig config = new SearchConfig.Builder("YourApplicationID", "YourAdminAPIKey").build();
SearchClient client = new SearchClient(config, new JavaNetHttpRequester(config));
SearchIndex index = client.initIndex("your_index_name");
// Enjoy!

Hope this helps!
Cheers,