Hi Folks ,
I was tried knnsearch for vector similarity search in python it worked .But Now i need to integrate that with my spring application , I don't see much resource on it. But i tried with below code
Elastic Search : 8.0.1
RestClient restClient = RestClient.builder(
new HttpHost("localhost", 9200)).build();
ElasticsearchTransport transport = new RestClientTransport(
restClient, new JacksonJsonpMapper());
ElasticsearchClient client = new ElasticsearchClient(transport);
KnnSearchQuery query = new KnnSearchQuery.Builder().field("image-vector").k(1).numCandidates(100).queryVector(v).build();
KnnSearchRequest request = new KnnSearchRequest.Builder().knn(query).index("image_similarity_1million").fields("humanid").build();
client.knnSearch(request,RequestOptions.DEFAULT);
But i am getting exceptions
Exception in thread "main" jakarta.json.JsonException: Jackson exception
at co.elastic.clients.json.jackson.JacksonUtils.convertException(JacksonUtils.java:39)
at co.elastic.clients.json.jackson.JacksonJsonpMapper$JacksonValueParser.deserialize(JacksonJsonpMapper.java:113)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:75)
at co.elastic.clients.json.JsonpMapperBase.deserialize(JsonpMapperBase.java:41)
at co.elastic.clients.json.AttributedJsonpMapper.deserialize(AttributedJsonpMapper.java:45)
at co.elastic.clients.json.JsonpDeserializer$1.deserialize(JsonpDeserializer.java:98)
at co.elastic.clients.json.NamedDeserializer.deserialize(NamedDeserializer.java:64)
at co.elastic.clients.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:72)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:176)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:137)
at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:85)
at co.elastic.clients.json.JsonpDeserializerBase$ArrayDeserializer.deserialize(JsonpDeserializerBase.java:320)
at co.elastic.clients.json.JsonpDeserializerBase$ArrayDeserializer.deserialize(JsonpDeserializerBase.java:285)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:75)
at co.elastic.clients.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:72)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:176)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:137)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:75)
at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:79)
at co.elastic.clients.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:72)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:176)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:137)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:75)
at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:79)
at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43)
at co.elastic.clients.transport.endpoints.EndpointWithResponseMapperAttr$1.deserialize(EndpointWithResponseMapperAttr.java:56)
at co.elastic.clients.transport.rest_client.RestClientTransport.decodeResponse(RestClientTransport.java:328)
at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:294)
at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:147)
at co.elastic.clients.elasticsearch.ElasticsearchClient.knnSearch(ElasticsearchClient.java:1010)
at Elastic.main(Elastic.java:37)
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `HUMAN` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (org.apache.http.nio.entity.ContentInputStream); line: 1, column: 250]
at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1764)
at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:400)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1209)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1400)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:362)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:195)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322)
at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:4569)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2798)
at co.elastic.clients.json.jackson.JacksonJsonpMapper$JacksonValueParser.deserialize(JacksonJsonpMapper.java:111)
... 29 more
please help me out.