Comments (5)
Thanks for the report @neowu. There is indeed an issue on this type's deserialization and we were able to identify it with the samples you've provided. We're working on a fix.
from elasticsearch-java.
Adding myself for visibility. This is a show stopping bug for me and my team. Our suggestions do not work currently because of this issue.
` Map<String, FieldSuggester> suggestersMap = new HashMap<>();
suggestersMap.put(field + ConstantsHelper.COMPLETION_STANDARD,
CompletionSuggester.of(suggester -> suggester
.field(field + ConstantsHelper.COMPLETION_STANDARD)
.prefix(query)
.skipDuplicates(true)
.size(ConstantsHelper.FIFTEEN_LITERAL))
._toFieldSuggester());
SearchRequest request = SearchRequest.of(r -> r
.index(elasticConfig.getSuggestionIndex())
.size(elasticConfig.getSearchHitSize())
.timeout(String.valueOf(String.format("%sms", elasticConfig.getConnectTimeout())))
.suggest(x -> x.text(query).suggesters(suggestersMap))
);`
from elasticsearch-java.
Hello,
For the Java API there is 2 problemes IMO:
- First suggest options map are determined by the map item's key : completion/phrase/term =+ # + <suggestion_name>
This suggest type is lost in the option's array parsing. - Second in the UnionDeserializer members of each kind are flatten in a Map indexed by field name. Unfortunatly fields names are not unique by types, so this case "completion" options are miss interpreted as "term"options.
Here is the flatten part of the union Deserializer :
JsonpDeserializer<?> unwrapped = DelegatingDeserializer.unwrap(deserializer);
if (unwrapped instanceof ObjectDeserializer) {
ObjectDeserializer<?> od = (ObjectDeserializer<?>) unwrapped;
Set<String> allFields = od.fieldNames();
Set<String> fields = new HashSet<>(allFields); // copy to update
for (UnionDeserializer.SingleMemberHandler<Union, Kind, Member> member: objectMembers) {
// Remove respective fields on both sides to keep specific ones
fields.removeAll(member.fields);
member.fields.removeAll(allFields);
}
UnionDeserializer.SingleMemberHandler<Union, Kind, Member> member = new SingleMemberHandler<>(tag, deserializer, fields);
objectMembers.add(member);
if (od.shortcutProperty() != null) {
// also add it as a string
addMember(Event.VALUE_STRING, tag, member);
}
} else {
UnionDeserializer.SingleMemberHandler<Union, Kind, Member> member = new SingleMemberHandler<>(tag, deserializer);
for (Event e: deserializer.nativeEvents()) {
addMember(e, tag, member);
}
}
May be kepping the ObjectDeserializer "as is" and implementing a "best macth" by field names in the UnionDeserializer#deserialize method will do the tricks ?
Or a safer option is to pass kind type information from map's key while processing the suggestion item.
if (member == null && event == Event.START_OBJECT && !objectMembers.isEmpty()) {
// Parse as an object to find matching field names
JsonObject object = parser.getObject();
for (String field: object.keySet()) {
member = objectMembers.get(field);
if (member != null) {
break;
}
}
if (member == null) {
member = fallbackObjectMember;
}
if (member != null) {
// Traverse the object we have inspected
parser = JsonpUtils.objectParser(object, mapper);
event = parser.next();
}
}
from elasticsearch-java.
The API specification has been fixed in elastic/elasticsearch-specification#1301
The next pass of code generation will fix the issue.
from elasticsearch-java.
SearchRequest request = SearchRequest.of(r -> r
.index(elasticConfig.getSuggestionIndex())
.size(elasticConfig.getSearchHitSize())
.timeout(String.valueOf(String.format("%sms", elasticConfig.getConnectTimeout())))
.suggest(x -> x.text(query).suggesters(suggestersMap))
@neowu
had you ever resolved this problem? I still occur this problem. can you help me?
from elasticsearch-java.
Related Issues (20)
- PutSynonymResponse: Failed to decode response HOT 2
- TermsBucketBase: doc_count_error should be doc_count_error_upper_bound HOT 1
- Read By Id: Failed to decode response
- Assign a tokenizer to a field when creating an index. 8.6.0 HOT 1
- co.elastic.clients.elasticsearch.ElasticsearchClient.delete responce nullpointerexception HOT 2
- Creating aggregation from json via supplied reader HOT 1
- Building a zero result response declares missing properties as mandatory which should be optional HOT 1
- `field_masking_span` is deprecated in ES8.0+ but still used in java client HOT 4
- Cannot parse DynamicTemplate mapping with unknown field HOT 5
- Encountering NoSuchMethodError when Creating Elasticsearch Client
- PutTemplateRequest - `Unknown field 'composed_of'` HOT 1
- Snowball token filter with default language breaks `indices.get()` HOT 1
- I can't disable the 'type#name' format in the deserialization of the response HOT 1
- New lightweight http layer based on JDK 11
- New http layer based on Apache HTTP 5.x
- Support for geo distance sort on nested fields HOT 2
- JsonpMappingException thrown when parsing explicitly null co.elastic.clients.elasticsearch._types.Script from Json HOT 1
- Deserilizing error calling the healthReport() method.
- AllocationRecord has no nodeRole method HOT 3
- What is the alternative to RestHighLevelClient for Spring Boot 3.3.0 and Java 21? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-java.