# GetTransformResponse unable to parse "source" field

**URL:** <https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305>\
**Category:** Elasticsearch\
**Tags:** language-clients, transforms\
**Created:** [November 4, 2020, 4:34pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305 "2020-11-04T16:34:10Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Craig\_Uss](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/craig_uss/32/78413_2.png) [@Craig\_Uss](https://discuss.elastic.co/u/Craig_Uss)\
**Post date:** [November 4, 2020, 4:34pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305/1 "2020-11-04T16:34:10Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 4, 2020, 4:43pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305/2 "2020-11-04T16:43:32Z")

</div>

Welcome!

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...

Basically you can put this in your `pom.xml`:

```auto
<properties>
  <elasticsearch.version>7.9.3<elasticsearch.version>
</properties>

```

See documentation here: [https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-customize-dependency-versions](https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-customize-dependency-versions)

---

<div class="post-metadata">

**Author:** ![Craig\_Uss](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/craig_uss/32/78413_2.png) [@Craig\_Uss](https://discuss.elastic.co/u/Craig_Uss)\
**Post date:** [November 4, 2020, 4:44pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305/3 "2020-11-04T16:44:26Z")

</div>

Thanks for the response.

Yes right now have it declared as  
`<elasticsearch.version>7.8.1</elasticsearch.version>`

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 4, 2020, 4:45pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305/4 "2020-11-04T16:45:29Z")

</div>

Could you share a bit of your code?

---

<div class="post-metadata">

**Author:** ![Craig\_Uss](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/craig_uss/32/78413_2.png) [@Craig\_Uss](https://discuss.elastic.co/u/Craig_Uss)\
**Post date:** [November 4, 2020, 4:49pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305/5 "2020-11-04T16:49:30Z")

</div>

Sure. Here is the transform that I created:

```auto
{
  "id": "bogus",
  "source": {
    "index": [
      "*bogus*"
    ],
    "query": {
      "bool": {
        "filter": [
          {
            "bool": {
              "should": [
                {
                  "exists": {
                    "field": "items.id"
                  }
                }
              ],
              "minimum_should_match": 1
            }
          },
          {
            "bool": {
              "should": [
                {
                  "exists": {
                    "field": "counter.type"
                  }
                }
              ],
              "minimum_should_match": 1
            }
          }
        ]
      }
    }
  },
  "dest": {
    "index": "bogus"
  },
  "sync": {
    "time": {
      "field": "@timestamp",
      "delay": "5m"
    }
  },
  "pivot": {
    "group_by": {
      "items.id.keyword": {
        "terms": {
          "field": "items.id.keyword"
        }
      },
      "@timestamp": {
        "date_histogram": {
          "field": "@timestamp",
          "calendar_interval": "1d"
        }
      }
    },
    "aggregations": {
      "unique_item_investigations": {
        "filter": {
          "bool": {
            "must": [
              {
                "term": {
                  "counter.type": "test"
                }
              },
              {
                "term": {
                  "event.metadata.double_click": false
                }
              }
            ]
          }
        },
        "aggs": {
          "cardinality_unique_item_investigations": {
            "cardinality": {
              "field": "counter.type.keyword"
            }
          }
        }
      }
    }
  },
  "description": "Bogus",
  "settings": {}
}

```

Here is the java snippet used to call and retrieve the transform

```auto
GetTransformRequest getTransformRequest = new GetTransformRequest(transformName);
        try {
            GetTransformResponse getTransformResponse = client.transform().getTransform(getTransformRequest, RequestOptions.DEFAULT);
            return getTransformResponse.getCount() > 0;
        } catch (ElasticsearchException e) {
            logger.info(String.format("Transform - %s - not found", transformName));
        }
        return false;

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 4, 2020, 5:22pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305/6 "2020-11-04T17:22:17Z")

</div>

Great thanks. I can reproduce the problem...

I opened

> <https://github.com/elastic/elasticsearch/issues/64602>
>
> Elasticsearch version (bin/elasticsearch --version): 7.9.3
> Steps to reproduce:
> I tried this code:
> @Test
> void transformApi() {
> try (RestHighLevelClient client = new RestHighLevelClient(
> RestClient.builder(HttpHost.create("http://localhost:9200"))))...

---

<div class="post-metadata">

**Author:** ![Craig\_Uss](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/craig_uss/32/78413_2.png) [@Craig\_Uss](https://discuss.elastic.co/u/Craig_Uss)\
**Post date:** [November 4, 2020, 6:34pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305/7 "2020-11-04T18:34:35Z")

</div>

Perfect, thank you so much!

---

<div class="post-metadata">

**Author:** ![BenTrent](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bentrent/32/33915_2.png) [@BenTrent](https://discuss.elastic.co/u/BenTrent)\
**Post date:** [November 5, 2020, 7:52pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305/8 "2020-11-05T19:52:28Z")

</div>

@Craig_Uss what are you supplying as your `NamedXContent` serializers in your high level rest client constructor?

The error

> unknown named object category [org.elasticsearch.index.query.QueryBuilder]

Indicates that for some reason the appropriate named xcontent serializers were not provided to the RestHighLevelClient object.

Please provide your RestHighLevelClient version information and how you are calling the constructor. That will help narrow this down.

---

<div class="post-metadata">

**Author:** ![BenTrent](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bentrent/32/33915_2.png) [@BenTrent](https://discuss.elastic.co/u/BenTrent)\
**Post date:** [November 5, 2020, 8:02pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305/9 "2020-11-05T20:02:58Z")

</div>

Digging around in the code, it seems that

```auto
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.

```auto
class HighLevelClient extends RestHighLevelClient {
       HighLevelClient(RestClient restClient) {
            super(restClient, RestClient::close, new SearchModule(Settings.EMPTY, Collections.emptyList()).getNamedXContents());
        }
    }
```

---

<div class="post-metadata">

**Author:** ![Craig\_Uss](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/craig_uss/32/78413_2.png) [@Craig\_Uss](https://discuss.elastic.co/u/Craig_Uss)\
**Post date:** [November 6, 2020, 6:56pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305/10 "2020-11-06T18:56:38Z")

</div>

```auto
class HighLevelClient extends RestHighLevelClient {
       HighLevelClient(RestClient restClient) {
            super(restClient, RestClient::close, new SearchModule(Settings.EMPTY, Collections.emptyList()).getNamedXContents());
        }
    }

```

This worked out for me! Thank you so much for your help on this!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 6, 2020, 7:18pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305/11 "2020-11-06T19:18:03Z")

</div>

Great. But I do think that end users should not have to care about that.  
It should be available OOTB.

---

<div class="post-metadata">

**Author:** ![Craig\_Uss](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/craig_uss/32/78413_2.png) [@Craig\_Uss](https://discuss.elastic.co/u/Craig_Uss)\
**Post date:** [November 6, 2020, 7:24pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305/12 "2020-11-06T19:24:45Z")

</div>

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)

```auto
XContentParser parser = JsonXContent.jsonXContent.createParser(new NamedXContentRegistry((new TransformNamedXContentProvider()).getNamedXContentParsers()), LoggingDeprecationHandler.INSTANCE, transformSource);
        TransformConfig transformConfig = TransformConfig.fromXContent(parser);

```

Is this the right approach for trying to create a PutTransformRequest? I can open a new thread if needed!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 4, 2020, 7:24pm UTC](https://discuss.elastic.co/t/gettransformresponse-unable-to-parse-source-field/254305/13 "2020-12-04T19:24:48Z")

</div>

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