Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reproduce the bug from Jackson deserialization of enum #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repositories {
dependencies {
// This dependency is used by the application.
implementation 'com.google.guava:guava:30.1.1-jre'
implementation 'com.meilisearch.sdk:meilisearch-java:0.11.0'
implementation 'com.meilisearch.sdk:meilisearch-java:0.11.1'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'org.json:json:20230227'
}
Expand Down
36 changes: 6 additions & 30 deletions app/src/main/java/javapp/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import com.meilisearch.sdk.*;
import com.meilisearch.sdk.model.MatchingStrategy;
import com.meilisearch.sdk.json.JacksonJsonHandler;
import com.meilisearch.sdk.model.TaskInfo;

import org.json.JSONArray;
import org.json.JSONObject;
Expand All @@ -14,39 +16,13 @@
public class App {
public static void main(String[] args) throws Exception {
try {
JSONArray array = new JSONArray();
ArrayList items = new ArrayList() {{
add(new JSONObject().put("id", "1").put("title", "Carol").put("genres",new JSONArray("[\"Romance\",\"Drama\"]")));
add(new JSONObject().put("id", "2").put("title", "Wonder Woman").put("genres",new JSONArray("[\"Action\",\"Adventure\"]")));
add(new JSONObject().put("id", "3").put("title", "Life of Pi").put("genres",new JSONArray("[\"Adventure\",\"Drama\"]")));
add(new JSONObject().put("id", "4").put("title", "Mad Max: Fury Road").put("genres",new JSONArray("[\"Adventure\",\"Science Fiction\"]")));
add(new JSONObject().put("id", "5").put("title", "Moana").put("genres",new JSONArray("[\"Fantasy\",\"Action\"]")));
add(new JSONObject().put("id", "6").put("title", "Philadelphia").put("genres",new JSONArray("[\"Drama\"]")));
}};
Client clientJackson = new Client(new Config("http://localhost:7700", "masterKey", new JacksonJsonHandler()));

array.put(items);
String documents = array.getJSONArray(0).toString();
System.out.println(clientJackson.health());

Client client = new Client(new Config("http://meilisearch:7700", "masterKey"));
TaskInfo taskJackson = clientJackson.createIndex("movies");

System.out.println(client.health());

Index index = client.index("movies");

// If the index 'movies' does not exist, Meilisearch creates it when you first add the documents.
index.addDocuments(documents);

Thread.sleep(1000);

SearchRequest searchRequest = new SearchRequest("w");
searchRequest.setFilter(new String[]{"mass < 200"});
searchRequest.setSort(new String[]{"mass:asc"});
searchRequest.setShowMatchesPosition(true);
searchRequest.setMatchingStrategy(MatchingStrategy.LAST);
searchRequest.setAttributesToHighlight(new String[]{"title", "description"});

System.out.println(searchRequest.toString());
System.out.println(client.index("movies").search(searchRequest));
System.out.println(taskJackson.getStatus());
} catch (Exception e) {
System.out.println(e);
}
Expand Down