❗ WARNING: this is a development version of the client. The latest release's readme is https://github.com/manticoresoftware/manticoresearch-java/tree/5.0.0
-
API version: 5.0.0
-
Build date: 2024-02-22T08:36:02.662182043Z[Etc/UTC]
Сlient for Manticore Search.
Building the API client library requires:
- Java 17+
- Maven/Gradle
Manticore Search | manticoresearch-java |
---|---|
dev | manticoresearch-dev |
>= 6.2.0 | >= 3.3.1 |
>= 2.5.1 | >= 2.0.2 |
To install the API client library to your local Maven repository, simply execute:
mvn clean install
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
mvn clean deploy
Refer to the OSSRH Guide for more information.
Add this dependency to your project's POM:
<dependency>
<groupId>com.manticoresearch</groupId>
<artifactId>manticoresearch-dev</artifactId>
<version>5.0.1</version>
<scope>compile</scope>
</dependency>
Add this dependency to your project's build file:
repositories {
mavenCentral() // Needed if the 'manticoresearch' jar has been published to maven central.
mavenLocal() // Needed if the 'manticoresearch' jar has been published to the local maven repo.
}
dependencies {
implementation "com.manticoresearch:manticoresearch:5.0.0"
}
At first generate the JAR by executing:
mvn clean package
Then manually install the following JARs:
target/manticoresearch-5.0.0.jar
target/lib/*.jar
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.*;
public class ApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://127.0.0.1:9308");
UtilsApi utilsApi = new UtilsApi(defaultClient);
utilsApi.sql("CREATE TABLE IF NOT EXISTS test (title text)", true);
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\"}}}\n";
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();
}
SearchApi searchApi = new SearchApi(defaultClient);
try {
// Create SearchRequest
SearchRequest searchRequest = new SearchRequest();
searchRequest.setIndex("test");
QueryFilter queryFilter = new QueryFilter();
queryFilter.setQueryString("Title 1");
searchRequest.setFulltextFilter(queryFilter);
// Perform a search
SearchResponse searchResponse = searchApi.search(searchRequest);
System.out.println( searchResponse.toString() );
} catch (ApiException e) {
System.err.println("Exception when calling SearchApi#search");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
All URIs are relative to http://127.0.0.1:9308
Class | Method | HTTP request | Description |
---|---|---|---|
IndexApi | bulk | POST /bulk | Bulk index operations |
IndexApi | delete | POST /delete | Delete a document in an index |
IndexApi | insert | POST /insert | Create a new document in an index |
IndexApi | replace | POST /replace | Replace new document in an index |
IndexApi | update | POST /update | Update a document in an index |
IndexApi | update_0 | POST /{index}/_update/{id} | Partially replaces a document in an index |
SearchApi | percolate | POST /pq/{index}/search | Perform reverse search on a percolate index |
SearchApi | search | POST /search | Performs a search on an index |
UtilsApi | sql | POST /sql | Perform SQL requests |
- Aggregation
- AggregationComposite
- AggregationCompositeSourcesInnerValue
- AggregationCompositeSourcesInnerValueTerms
- AggregationSortInnerValue
- AggregationTerms
- BoolFilter
- BulkResponse
- DeleteDocumentRequest
- DeleteResponse
- EqualsFilter
- ErrorResponse
- Facet
- FilterBoolean
- FilterNumber
- FilterString
- GeoDistanceFilter
- GeoDistanceFilterLocationAnchor
- Highlight
- HighlightField
- InFilter
- InsertDocumentRequest
- KnnQueryByDocId
- KnnQueryByVector
- MatchFilter
- MatchOp
- MatchOpFilter
- MatchPhraseFilter
- NotFilterBoolean
- NotFilterNumber
- NotFilterString
- PercolateRequest
- PercolateRequestQuery
- QueryFilter
- RangeFilter
- RangeFilterValue
- ReplaceDocumentRequest
- SearchRequest
- SearchRequestKnn
- SearchResponse
- SearchResponseHits
- SortMVA
- SortMultiple
- SortOrder
- SourceByRules
- SuccessResponse
- UpdateDocumentRequest
- UpdateResponse
All endpoints do not require authorization. Authentication schemes defined for the API:
It's recommended to create an instance of ApiClient
per thread in a multithreaded environment to avoid any potential issues.