ELK 7.8.1
Using Springboot 2.2.5
I am able to create a transform using the Kibana Stack Management and using the PUT _transform curl command. However when trying to retrieve the same transform using the High Level REST client, I receive the following error:
Caused by: org.elasticsearch.common.xcontent.XContentParseException: [1:137] [transform_config_source] failed to parse field [query]
at org.elasticsearch.common.xcontent.ObjectParser.parseValue(ObjectParser.java:531) ~[elasticsearch-x-content-7.8.1.jar:7.8.1]
at org.elasticsearch.common.xcontent.ObjectParser.parseSub(ObjectParser.java:541) ~[elasticsearch-x-content-7.8.1.jar:7.8.1]
at org.elasticsearch.common.xcontent.ObjectParser.parse(ObjectParser.java:324) ~[elasticsearch-x-content-7.8.1.jar:7.8.1]
at org.elasticsearch.common.xcontent.ConstructingObjectParser.parse(ConstructingObjectParser.java:171) ~[elasticsearch-x-content-7.8.1.jar:7.8.1]
at org.elasticsearch.common.xcontent.ConstructingObjectParser.apply(ConstructingObjectParser.java:163) ~[elasticsearch-x-content-7.8.1.jar:7.8.1]
at org.elasticsearch.client.transform.transforms.TransformConfig.lambda$static$1(TransformConfig.java:99) ~[elasticsearch-rest-high-level-client-7.8.1.jar:7.8.1]
at org.elasticsearch.common.xcontent.AbstractObjectParser.lambda$declareObject$1(AbstractObjectParser.java:169) ~[elasticsearch-x-content-7.8.1.jar:7.8.1]
at org.elasticsearch.common.xcontent.ObjectParser.lambda$declareField$9(ObjectParser.java:386) ~[elasticsearch-x-content-7.8.1.jar:7.8.1]
at org.elasticsearch.common.xcontent.ObjectParser.parseValue(ObjectParser.java:529) ~[elasticsearch-x-content-7.8.1.jar:7.8.1]
... 47 common frames omitted
Caused by: org.elasticsearch.common.xcontent.XContentParseException: unknown named object category [org.elasticsearch.index.query.QueryBuilder]
at org.elasticsearch.common.xcontent.NamedXContentRegistry.parseNamedObject(NamedXContentRegistry.java:128) ~[elasticsearch-x-content-7.8.1.jar:7.8.1]
at org.elasticsearch.common.xcontent.support.AbstractXContentParser.namedObject(AbstractXContentParser.java:385) ~[elasticsearch-x-content-7.8.1.jar:7.8.1]
at org.elasticsearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder(AbstractQueryBuilder.java:320) ~[elasticsearch-7.8.1.jar:7.8.1]
at org.elasticsearch.client.transform.transforms.QueryConfig.fromXContent(QueryConfig.java:39) ~[elasticsearch-rest-high-level-client-7.8.1.jar:7.8.1]
at org.elasticsearch.client.transform.transforms.SourceConfig.lambda$static$1(SourceConfig.java:56) ~[elasticsearch-rest-high-level-client-7.8.1.jar:7.8.1]
at org.elasticsearch.common.xcontent.AbstractObjectParser.lambda$declareObject$1(AbstractObjectParser.java:169) ~[elasticsearch-x-content-7.8.1.jar:7.8.1]
at org.elasticsearch.common.xcontent.ObjectParser.lambda$declareField$9(ObjectParser.java:386) ~[elasticsearch-x-content-7.8.1.jar:7.8.1]
at org.elasticsearch.common.xcontent.ObjectParser.parseValue(ObjectParser.java:529) ~[elasticsearch-x-content-7.8.1.jar:7.8.1]
... 55 common frames omitted
What are the dependencies you declared for your project?
Asking because when using springboot with elasticsearch, you need to be explicit with some transitive dependencies as SpringBoot declares a version 6.4...
static List<NamedXContentRegistry.Entry> getProvidedNamedXContents() {
List<NamedXContentRegistry.Entry> entries = new ArrayList<>();
for (NamedXContentProvider service : ServiceLoader.load(NamedXContentProvider.class)) {
entries.addAll(service.getNamedXContentParsers());
}
return entries;
}
In a 7.8 high level rest client loads all the xcontent parsers for the included plugins. If the search plugin is not included, it won't be loaded I think.
EDIT:
Here is a way to construct a client that includes the SearchModule xcontent serializers.
class HighLevelClient extends RestHighLevelClient {
HighLevelClient(RestClient restClient) {
super(restClient, RestClient::close, new SearchModule(Settings.EMPTY, Collections.emptyList()).getNamedXContents());
}
}
I agree. What I am having trouble with reconciling is building a Transform. In other API operations, I usually have the option to provide the Json source to build the object. Here I have to create a xContentParser. Something like the below (yet to get it to work, but just to give you an idea)
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.