Skip to content

Instantly share code, notes, and snippets.

@akahn
Created November 5, 2013 02:26
Show Gist options
  • Select an option

  • Save akahn/7312832 to your computer and use it in GitHub Desktop.

Select an option

Save akahn/7312832 to your computer and use it in GitHub Desktop.
Trying to understand elasticsearch's schema and types
$ curl -XPOST http://localhost:9200/myindex/mytype -d '{"foo": ["bar"]}'
{"ok":true,"_index":"myindex","_type":"mytype","_id":"YYfPUL3TQLaL17zhXQ-ELw","_version":1}
$ curl -XPOST http://localhost:9200/myindex/mytype -d '{"foo": [{"foo": "bar"}]}'
{"error":"MapperParsingException[Failed to parse [foo]]; nested: ElasticSearchIllegalArgumentException[unknown property [foo]]; ","status":400}
$ curl -XDELETE http://localhost:9200/myindex/mytype
{"ok":true}
$ curl -XPOST http://localhost:9200/myindex/mytype -d '{"foo": [{"foo": "bar"}]}'
{"ok":true,"_index":"myindex","_type":"mytype","_id":"6Sv7aaBXTu2jH_wYXR4SYg","_version":1}
$ curl -XPOST http://localhost:9200/myindex/mytype -d '{"foo": ["bar"]}'
{"error":"MapperParsingException[object mapping [foo] trying to serialize a value with no field associated with it, current value [bar]]","status":400}
# Why are a list ["foo"] and a list of objects [{"foo": "bar"}] incompatible?
# How should I rearrange my data for storage in an elasticsearch document?
@akahn

akahn commented Nov 5, 2013

Copy link
Copy Markdown
Author

@karmi You're right. I think I thought they should be compatible because I misunderstood elasticsearch's definition of 'schemaless'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment