sanikolaev / manticoresearch-java

Official Java client for Manticore Search

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

manticoresearch

Low-level client for Manticore Search.

❗ WARNING: this is a development version of the client. The latest release's readme is https://github.com/manticoresoftware/manticoresearch-java/tree/2.0.3

Requirements

Building the API client library requires:

  1. Java 1.8+
  2. Maven/Gradle

Minimum Manticore Search version is 2.5.1 with HTTP protocol enabled.

Installation

Add this dependency to your project's POM:

<dependency>
  <groupId>com.manticoresearch</groupId>
  <artifactId>manticoresearch</artifactId>
  <version>3.2.0</version>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "com.manticoresearch:manticoresearch:3.2.0"

Others

At first generate the JAR by executing:

mvn clean package

Then manually install the following JARs:

  • target/manticoresearch-3.2.0.jar
  • target/lib/*.jar

Getting Started

Please follow the installation instruction and execute the following Java code:

import com.manticoresearch.client.*;
import com.manticoresearch.client.auth.*;
import com.manticoresearch.client.model.*;
import com.manticoresearch.client.api.IndexApi;

public class IndexApiExample {

    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://127.0.0.1:9308");
        
        IndexApi apiInstance = new IndexApi(defaultClient);
        String body = ["'{\"insert\": {\"index\": \"test\", \"id\": 1, \"doc\": {\"title\": \"Title 1\"}}},\\n{\"insert\": {\"index\": \"test\", \"id\": 2, \"doc\": {\"title\": \"Title 2\"}}}'"]; // String | 
        try {
            BulkResponse result = apiInstance.bulk(body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling IndexApi#bulk");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Documentation

Full documentation is available in docs folder.

Manticore Search server documentation: https://manual.manticoresearch.com.

Documentation for API Endpoints

All URIs are relative to http://127.0.0.1:9308

Class Method HTTP request Description
IndexApi bulk POST /json/bulk Bulk index operations
IndexApi delete POST /json/delete Delete a document in an index
IndexApi insert POST /json/insert Create a new document in an index
IndexApi replace POST /json/replace Replace new document in an index
IndexApi update POST /json/update Update a document in an index
SearchApi percolate POST /json/pq/{index}/search Perform reverse search on a percolate index
SearchApi search POST /json/search Performs a search
UtilsApi sql POST /sql Perform SQL requests

Documentation for Models

Documentation for Authorization

All endpoints do not require authorization. Authentication schemes defined for the API:

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

Author

info@manticoresearch.com

About

Official Java client for Manticore Search

License:MIT License


Languages

Language:Java 98.5%Language:Shell 0.8%Language:Scala 0.7%