You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by Kasper Sørensen <i....@gmail.com> on 2016/04/26 00:22:13 UTC

Approach to submitting ElasticSearch mapping

Hi all,

I am working on a small tool that is populating an ElasticSearch index and
ran into an issue that I want to ask about... It seems that our
ElasticSearchUtils class is creating the 'source' of the mapping request
and that it contains an array of property name and then property details
like 'type=string&store=true'. I am wondering how/why this format is used.
Everywhere else I see a nested JSON object describing the document mapping.
And when building my tool this also seemed to be the only thing I could get
working. If I used the current MetaModel implementation then I get some
funky error messages back from ES saying that it's not proper xcontent.

If anyone knows why it is as it is, I'd love to know :) Or is it just a
plain bug?

Best regards,
Kasper

RE: Approach to submitting ElasticSearch mapping

Posted by Kasper Sørensen <i....@gmail.com>.
Ok I have patch to turn it into a map instead. Will post a PR a bit later
then.
Den 26. apr. 2016 12.15 AM skrev "Du Krøger, Dennis" <
Dennis.DuKroger@humaninference.com>:

> Hmmm... I guess it only fail for jest? It is moved into common from the
> original native version, and the ES 1.4.4 PutMappingRequestBuilder
> explicitly supports this:
> https://github.com/elastic/elasticsearch/blob/v1.4.4/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java
> (See "public PutMappingRequestBuilder setSource(Object... source)"
>
> PutMappingRequestBuilder also seems to support a map, and Jest/GSON has a
> MapTypeAdapterFactory for converting the payload, so I guess the simplest
> fix to just use a map instead.
>
> BR,
> Dennis
>
> -----Original Message-----
> From: Kasper Sørensen [mailto:i.am.kasper.sorensen@gmail.com]
> Sent: 26. april 2016 00:22
> To: dev@metamodel.apache.org
> Subject: Approach to submitting ElasticSearch mapping
>
> Hi all,
>
> I am working on a small tool that is populating an ElasticSearch index and
> ran into an issue that I want to ask about... It seems that our
> ElasticSearchUtils class is creating the 'source' of the mapping request
> and that it contains an array of property name and then property details
> like 'type=string&store=true'. I am wondering how/why this format is used.
> Everywhere else I see a nested JSON object describing the document mapping.
> And when building my tool this also seemed to be the only thing I could
> get working. If I used the current MetaModel implementation then I get some
> funky error messages back from ES saying that it's not proper xcontent.
>
> If anyone knows why it is as it is, I'd love to know :) Or is it just a
> plain bug?
>
> Best regards,
> Kasper
>

RE: Approach to submitting ElasticSearch mapping

Posted by Du, Dennis <De...@HumanInference.com>.
Hmmm... I guess it only fail for jest? It is moved into common from the original native version, and the ES 1.4.4 PutMappingRequestBuilder explicitly supports this: https://github.com/elastic/elasticsearch/blob/v1.4.4/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java (See "public PutMappingRequestBuilder setSource(Object... source)"

PutMappingRequestBuilder also seems to support a map, and Jest/GSON has a MapTypeAdapterFactory for converting the payload, so I guess the simplest fix to just use a map instead.

BR,
Dennis

-----Original Message-----
From: Kasper Sørensen [mailto:i.am.kasper.sorensen@gmail.com] 
Sent: 26. april 2016 00:22
To: dev@metamodel.apache.org
Subject: Approach to submitting ElasticSearch mapping

Hi all,

I am working on a small tool that is populating an ElasticSearch index and ran into an issue that I want to ask about... It seems that our ElasticSearchUtils class is creating the 'source' of the mapping request and that it contains an array of property name and then property details like 'type=string&store=true'. I am wondering how/why this format is used.
Everywhere else I see a nested JSON object describing the document mapping.
And when building my tool this also seemed to be the only thing I could get working. If I used the current MetaModel implementation then I get some funky error messages back from ES saying that it's not proper xcontent.

If anyone knows why it is as it is, I'd love to know :) Or is it just a plain bug?

Best regards,
Kasper