Skip to content

Commit

Permalink
Added partial replace functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
nick committed Mar 7, 2024
1 parent 6787fd9 commit 5e05c60
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 3 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ jobs:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: maven
- name: Use Maven
- name: Check for dev-version
if: ${{ contains(github.ref, 'master') }}
run: |
VERSION=`git log -1 --date=format:"%y%m%d%H" --format=%cd-%h|head`
echo "version $VERSION"
sed -i -E "s/(\<version\>)([0-9]\.[0-9]\.)(.*)(\<)/\1\2$VERSION\4/1" pom.xml
- name: Publish
run: |
mkdir -p ~/.m2
export GPG_TTY=$(tty)
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

Building the API client library requires:

1. Java 1.8+
1. Java 17+
2. Maven/Gradle

| Manticore Search | manticoresearch-java |
Expand Down Expand Up @@ -143,6 +143,7 @@ Class | Method | HTTP request | Description
*IndexApi* | [**insert**](docs/IndexApi.md#insert) | **POST** /insert | Create a new document in an index
*IndexApi* | [**replace**](docs/IndexApi.md#replace) | **POST** /replace | Replace new document in an index
*IndexApi* | [**update**](docs/IndexApi.md#update) | **POST** /update | Update a document in an index
*IndexApi* | [**update_0**](docs/IndexApi.md#update_0) | **POST** /{index}/_update/{id} | Partially replaces a document in an index
*SearchApi* | [**percolate**](docs/SearchApi.md#percolate) | **POST** /pq/{index}/search | Perform reverse search on a percolate index
*SearchApi* | [**search**](docs/SearchApi.md#search) | **POST** /search | Performs a search on an index
*UtilsApi* | [**sql**](docs/UtilsApi.md#sql) | **POST** /sql | Perform SQL requests
Expand Down Expand Up @@ -182,6 +183,7 @@ Class | Method | HTTP request | Description
- [PercolateRequestQuery](docs/PercolateRequestQuery.md)
- [QueryFilter](docs/QueryFilter.md)
- [RangeFilter](docs/RangeFilter.md)
- [ReplaceDocumentRequest](docs/ReplaceDocumentRequest.md)
- [SearchRequest](docs/SearchRequest.md)
- [SearchRequestKnn](docs/SearchRequestKnn.md)
- [SearchResponse](docs/SearchResponse.md)
Expand Down
16 changes: 16 additions & 0 deletions docs/ReplaceDocumentRequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


# ReplaceDocumentRequest

Object with document data.

## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**doc** | **Map&lt;String, Object&gt;** | Object with document data | |





2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>manticoresearch-dev</artifactId>
<packaging>jar</packaging>
<name>manticoresearch-dev</name>
<version>5.0.1</version>
<version>5.1.1</version>
<url>https://github.com/manticoresoftware/manticoresearch-java</url>
<description>Client for Manticore Search</description>
<scm>
Expand Down
66 changes: 66 additions & 0 deletions src/main/java/com/manticoresearch/client/api/IndexApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

import jakarta.ws.rs.core.GenericType;

import java.math.BigDecimal;
import com.manticoresearch.client.model.BulkResponse;
import com.manticoresearch.client.model.DeleteDocumentRequest;
import com.manticoresearch.client.model.DeleteResponse;
import com.manticoresearch.client.model.ErrorResponse;
import com.manticoresearch.client.model.InsertDocumentRequest;
import com.manticoresearch.client.model.ReplaceDocumentRequest;
import com.manticoresearch.client.model.SuccessResponse;
import com.manticoresearch.client.model.UpdateDocumentRequest;
import com.manticoresearch.client.model.UpdateResponse;
Expand Down Expand Up @@ -293,4 +295,68 @@ public ApiResponse<UpdateResponse> updateWithHttpInfo(UpdateDocumentRequest upda
new LinkedHashMap<>(), new LinkedHashMap<>(), new LinkedHashMap<>(), localVarAccept, localVarContentType,
null, localVarReturnType, false);
}

/**
* Partially replaces a document in an index
* Partially replaces a document with given id in an index Responds with an object of the following format: &#x60;&#x60;&#x60; {&#39;_index&#39;:&#39;products&#39;,&#39;updated&#39;:1} &#x60;&#x60;&#x60;
* @param index Name of the percolate index (required)
* @param id Id of the document to replace (required)
* @param replaceDocumentRequest (required)
* @return UpdateResponse
* @throws ApiException if fails to make API call
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> item updated </td><td> - </td></tr>
<tr><td> 0 </td><td> error </td><td> - </td></tr>
</table>
*
* @see <a href="https://manual.manticoresearch.com/Updating_documents/REPLACE#JSON-REPLACE">Partially replaces a document in an index Documentation</a>
*/
public UpdateResponse update_0(String index, BigDecimal id, ReplaceDocumentRequest replaceDocumentRequest) throws ApiException {
return update_0WithHttpInfo(index, id, replaceDocumentRequest).getData();
}

/**
* Partially replaces a document in an index
* Partially replaces a document with given id in an index Responds with an object of the following format: &#x60;&#x60;&#x60; {&#39;_index&#39;:&#39;products&#39;,&#39;updated&#39;:1} &#x60;&#x60;&#x60;
* @param index Name of the percolate index (required)
* @param id Id of the document to replace (required)
* @param replaceDocumentRequest (required)
* @return ApiResponse&lt;UpdateResponse&gt;
* @throws ApiException if fails to make API call
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> item updated </td><td> - </td></tr>
<tr><td> 0 </td><td> error </td><td> - </td></tr>
</table>
*
* @see <a href="https://manual.manticoresearch.com/Updating_documents/REPLACE#JSON-REPLACE">Partially replaces a document in an index Documentation</a>
*/
public ApiResponse<UpdateResponse> update_0WithHttpInfo(String index, BigDecimal id, ReplaceDocumentRequest replaceDocumentRequest) throws ApiException {
Object localVarPostBody = replaceDocumentRequest;
// Check required parameters
if (index == null) {
throw new ApiException(400, "Missing the required parameter 'index' when calling update_0");
}
if (id == null) {
throw new ApiException(400, "Missing the required parameter 'id' when calling update_0");
}
if (replaceDocumentRequest == null) {
throw new ApiException(400, "Missing the required parameter 'replaceDocumentRequest' when calling update_0");
}

// Path parameters
String localVarPath = "/{index}/_update/{id}"
.replaceAll("\\{index}", apiClient.escapeString(index))
.replaceAll("\\{id}", apiClient.escapeString(id.toString()));

String localVarAccept = apiClient.selectHeaderAccept("application/json");
String localVarContentType = apiClient.selectHeaderContentType("application/json");
GenericType<UpdateResponse> localVarReturnType = new GenericType<UpdateResponse>() {};
return apiClient.invokeAPI("IndexApi.update_0", localVarPath, "POST", new ArrayList<>(), localVarPostBody,
new LinkedHashMap<>(), new LinkedHashMap<>(), new LinkedHashMap<>(), localVarAccept, localVarContentType,
null, localVarReturnType, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* Manticore Search Client
* Сlient for Manticore Search.
*
* The version of the OpenAPI document: 3.3.1
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


package com.manticoresearch.client.model;

import java.util.Objects;
import java.util.Map;
import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.manticoresearch.client.JSON;


/**
* Object with document data.
*/
@JsonPropertyOrder({
ReplaceDocumentRequest.JSON_PROPERTY_DOC
})
@JsonTypeName("replaceDocumentRequest")
@JsonIgnoreProperties(ignoreUnknown = true)
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-07T07:34:08.520168146Z[Etc/UTC]")
public class ReplaceDocumentRequest {
public static final String JSON_PROPERTY_DOC = "doc";
private Map<String, Object> doc = new HashMap<>();

public ReplaceDocumentRequest() {
}

public ReplaceDocumentRequest doc(Map<String, Object> doc) {
this.doc = doc;
return this;
}

public ReplaceDocumentRequest putDocItem(String key, Object docItem) {
if (this.doc == null) {
this.doc = new HashMap<>();
}
this.doc.put(key, docItem);
return this;
}

/**
* Object with document data
* @return doc
**/
@jakarta.annotation.Nonnull
@JsonProperty(JSON_PROPERTY_DOC)
@JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.ALWAYS)

public Map<String, Object> getDoc() {
return doc;
}


@JsonProperty(JSON_PROPERTY_DOC)
@JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.ALWAYS)
public void setDoc(Map<String, Object> doc) {
this.doc = doc;
}


/**
* Return true if this replaceDocumentRequest object is equal to o.
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ReplaceDocumentRequest replaceDocumentRequest = (ReplaceDocumentRequest) o;
return Objects.equals(this.doc, replaceDocumentRequest.doc);
}

@Override
public int hashCode() {
return Objects.hash(doc);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ReplaceDocumentRequest {\n");
sb.append(" doc: ").append(toIndentedString(doc)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}

}

0 comments on commit 5e05c60

Please sign in to comment.