Comments (6)
Thanks for the feedback @fredy-scs. This is indeed something we have considered but haven't implemented yet. I'll make sure it's listed explicitely on the roadmap.
from elasticsearch-java.
Aha, that's the problems I've faced too. Please notice me if it is solved.
from elasticsearch-java.
this is the workaround I have so far:
public static <T extends JsonpSerializable, B extends ObjectBuilderBase> B toObjectBuilder(
T obj,
Supplier<B> createBuilder,
Predicate<String> fieldFilter) {
B builder = createBuilder.get();
Class<?> objClass = obj.getClass();
Class<?> builderClass = builder.getClass();
for (Method method : objClass.getMethods()) {
if (fieldFilter.test(method.getName()) && method.getParameterTypes().length == 0 &&
!Void.class.equals(method.getReturnType())) {
// look at public, no parameter, not void return type methods. likely field accessors
// try look for a corresponding builder method
Method builderMethod;
try {
builderMethod = builderClass.getMethod(method.getName(), method.getReturnType());
} catch (NoSuchMethodException e) {
// the corresponding method does not exist in builder, skip
continue;
}
try {
// see if this is part of an union field
Method kindMethod = objClass.getMethod("is" + StringUtils.capitalize(method.getName()));
if (kindMethod.getReturnType().equals(boolean.class)) {
if (!(boolean) kindMethod.invoke(obj)) {
// a union kind, and the current value is not this kind
continue;
}
}
} catch (NoSuchMethodException e) {
// not a union field
} catch (IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException("Unable to convert to builder.", e);
}
try {
builderMethod.invoke(builder, method.invoke(obj));
} catch (IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException("Unable to convert to builder.", e);
}
}
}
return builder;
}
from elasticsearch-java.
We have the same problem, hope it can come soon!
from elasticsearch-java.
any news on this one?
from elasticsearch-java.
Was this abandoned? Would really like to see this functionality added.
I have a similar situation where I would like one part of my code to build the parts of the query that are context specific and have another part of my code "append" additional conditions to the query that are common to all requests. In my case it would be fields used for authorization.
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 1
- 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.