I agree with David, type by developer is feasible approach here if you
don't have too many developers.
Another approach is to add suffix to field names that would correspond to
field types. This way your example would become:
curl localhost:9200/myindex/mytype/1 -d '{"well_obj": {"hi_str":"there"}}'
curl localhost:9200/myindex/mytype/2 -d '{"well_str": "hey"}'
You can even control how newly added fields are mapped using
dynamic_templateshttp://www.elasticsearch.org/guide/reference/mapping/root-object-type.html
.
On Monday, December 17, 2012 3:59:56 AM UTC-8, David Pilato wrote:
Perhaps you can design your system with a type by developper?
The problem is that you can't mute a field from an object to a String or
from a String to a Date.
Can't you handle it when your XML file is converted in JSON before it's
sent to Elasticsearch?
Sorry if I can't help you more...
David.
Le 17 décembre 2012 à 12:39, Amy <amybl...@gmail.com <javascript:>> a
écrit :
Hi David,
Thank you for the quick response!
These json files are from our CMS for our website.
These start their lives as xml files that contain website content and
format configuration and are transformed into json and deployed to
elasticsearch.
The webserver searches by user type etc, parses the json and serves it up
on the website.
We have many different content editors and web developers creating this
xml (it is generated from forms in our cms, so difficult to change the
format). Each form is generally created by a different web developer which
generates a different structure of xml (and then json), so the problem
would occur if 2 different web developers decided to use the field "well"
in a different way, or if they changed their form but kept the existing
json in elasticsearch.
Thanks.
On Monday, December 17, 2012 10:23:49 AM UTC, David Pilato wrote:
You can not modify core objects once mapping has been defined (or
automapping just did it for you).
So your first command created a mapping with well defined as an object
with a String field "hi".
Second command try to insert a String in place of your object.
But, what do you want to achieve?
Could you consider this kind of structure?
curl localhost:9200/myindex/mytype/1 -d '{"well": ["hi","there"]}'
I don't understand your use case and what is the reason you have to
design your docs like this.
David.
Le 17 décembre 2012 à 10:21, Amy < amybl...@gmail.com> a écrit :
Hi,
I was wondering if there was a way that a single json object/string could
have multiple mappings to solve the following problem:
I add one json doc:
curl localhost:9200/myindex/mytype/1 -d '{"well": {"hi":"there"}}'
Someone else adds another doc:
curl localhost:9200/myindex/mytype/2 -d '{"well": "hey"}'
And they get the following error:
{"error":"MapperParsingException[object mapping for [mytype] tried to
parse as object, but got EOF, has a concrete value been provided to
it?]","status":400}
Moreover, if the documents are uploaded in the other order, "well" is
mapped as a string, and the term "well.hi" = "there" is not searchable.
This does not happen if the docs have different indexes or types, but I
don't want to create too many types. Another workaround that I can see is
to have everyone enter their own unique wrapper for the json. So:
curl localhost:9200/myindex/mytype/2 -d '{"myuniquewrapper":{"well":
"hey"}}'
but it's a bit messy.
Any better ideas?
--
--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
--
--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
--