Skip to content

Commit

Permalink
fix spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Kirill Ostanin <[email protected]>
  • Loading branch information
Kirill Ostanin committed Oct 23, 2023
1 parent d005c76 commit 50889eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
package org.opensearch.client.opensearch._types.query_dsl;

import jakarta.json.stream.JsonGenerator;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
Expand All @@ -17,9 +19,6 @@
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.ObjectBuilder;

import javax.annotation.Nullable;
import java.util.function.Function;

@JsonpDeserializable
public class NeuralQuery extends QueryBase implements QueryVariant {

Expand All @@ -29,7 +28,6 @@ public class NeuralQuery extends QueryBase implements QueryVariant {
@Nullable
private final String modelId;


private NeuralQuery(NeuralQuery.Builder builder) {
super(builder);

Expand Down Expand Up @@ -189,8 +187,8 @@ public NeuralQuery build() {
}

public static final JsonpDeserializer<NeuralQuery> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
NeuralQuery.Builder::new,
NeuralQuery::setupNeuralQueryDeserializer
NeuralQuery.Builder::new,
NeuralQuery::setupNeuralQueryDeserializer
);

protected static void setupNeuralQueryDeserializer(ObjectDeserializer<NeuralQuery.Builder> op) {
Expand All @@ -200,7 +198,6 @@ protected static void setupNeuralQueryDeserializer(ObjectDeserializer<NeuralQuer
op.add(NeuralQuery.Builder::modelId, JsonpDeserializer.stringDeserializer(), "model_id");
op.add(NeuralQuery.Builder::k, JsonpDeserializer.integerDeserializer(), "k");


op.setKey(NeuralQuery.Builder::field, JsonpDeserializer.stringDeserializer());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,7 @@ public void testNestedVariantsWithContainerProperties() {
public void testNeuralQuery() {

SearchRequest searchRequest = SearchRequest.of(
s -> s.query(
q -> q.neural(n -> n.field("passage_embedding")
.queryText("Hi world")
.modelId("bQ1J8ooBpBj3wT4HVUsb")
.k(100)
)
)
s -> s.query(q -> q.neural(n -> n.field("passage_embedding").queryText("Hi world").modelId("bQ1J8ooBpBj3wT4HVUsb").k(100)))
);

assertEquals("passage_embedding", searchRequest.query().neural().field());
Expand All @@ -228,19 +222,19 @@ public void testNeuralQuery() {
@Test
public void testNeuralQueryFromJson() {

String json = "{\n" +
" \"from\": 0,\n" +
" \"size\": 100,\n" +
" \"query\": {\n" +
" \"neural\": {\n" +
" \"passage_embedding\": {\n" +
" \"query_text\": \"Hi world\",\n" +
" \"model_id\": \"bQ1J8ooBpBj3wT4HVUsb\",\n" +
" \"k\": 100\n" +
" }\n" +
" }\n" +
" }\n" +
"}";
String json = "{\n"
+ " \"from\": 0,\n"
+ " \"size\": 100,\n"
+ " \"query\": {\n"
+ " \"neural\": {\n"
+ " \"passage_embedding\": {\n"
+ " \"query_text\": \"Hi world\",\n"
+ " \"model_id\": \"bQ1J8ooBpBj3wT4HVUsb\",\n"
+ " \"k\": 100\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";

SearchRequest searchRequest = ModelTestCase.fromJson(json, SearchRequest.class, mapper);

Expand Down

0 comments on commit 50889eb

Please sign in to comment.