Java Api Client TermsQueryBuilder how to add terms from collection of strings

Hello.
The only available method is by ObjectBuilder value(List v) method.
Why there is no option to add just a list of Strings?

I am using Elasticsearch-java-7.16.2 version

I had to finish with something like that:
.terms(tqf -> tqf.value(fClasses.stream().map(FieldValue::of).collect(Collectors.toList())))))
which in my opinion doesn't look pretty.
There should be a better way, isn't it?

The FieldValue class represents the various value types of index fields. This is indeed unnecessarily complex.

A way to simplify things would be to add an additional method to FieldValue:
static List<FieldValue> of(List<String> list)
which would then allow writing:

.terms (tqf -> tqf.value(FieldValue.of(fClasses)))

Would that help? And of course similar methods would be added for collection/arrays of other types supported by FieldValue

Yes, that would be useful, but what about adding an additional method to TermsQueryField$Builder:

public ObjectBuilder<TermsQueryField> value(List<String> v)

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.