Hi everyone, I’m having a problem with bulk insert.
Here is my table:
CREATE TABLE test_data
(
domain text,
bidPublishTime bigint,
randomNum integer,
oriBidTitle text,
url text,
content text,
randomString json
) charset_table = 'non_cjk,chinese' morphology = 'icu_chinese';
My java code is:
package com.lp.manticoresearch;
import com.manticoresearch.client.ApiClient;
import com.manticoresearch.client.ApiException;
import com.manticoresearch.client.Configuration;
import com.manticoresearch.client.api.IndexApi;
import com.manticoresearch.client.api.SearchApi;
import com.manticoresearch.client.model.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TestMain {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://172.19.104.159:9308");
IndexApi indexApi = new IndexApi(defaultClient);
String body = "";
body = "{\"insert\": {\"index\" : \"products\", \"id\" : 1, \"doc\" : {\"title\" : \"Crossbody Bag with Tassel\", \"price\" : 19.85}}}"+"\n"+
"{\"insert\": {\"index\" : \"products\", \"id\" : 4, \"doc\" : {\"title\" : \"microfiber sheet set\", \"price\" : 19.99}}}"+"\n"+
"{\"insert\": {\"index\" : \"products\", \"id\" : 5, \"doc\" : {\"title\" : \"CPet Hair Remover Glove\", \"price\" : 7.99}}}"+"\n";
try {
BulkResponse response = indexApi.bulk(body);
System.out.println("Bulk insert response: " + response);
} catch (Exception e) {
System.err.println("Error during bulk insert: " + e.getMessage());
e.printStackTrace();
}
}
}
I got MismatchedInputException: Cannot deserialize value of type
com.manticoresearch.client.model.BulkResponsefrom Array value (token
JsonToken.START_ARRAY)
when I try to bulk insert data.
Then I tried HTTP request and that didn’t work either:
I don’t know what went wrong, please help me.
manticore version: 6.3.6
java version: jdk 21