Created
November 5, 2013 02:26
-
-
Save akahn/7312832 to your computer and use it in GitHub Desktop.
Trying to understand elasticsearch's schema and types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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? |
Aha: I just needed to set "enabled":false
on foo http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-object-type.html#_enabled_3
@akahn, well, it could be argued that ["foo"]
and [{"foo" : "bar"}]
are quite a different thing. Why do you think these two should be compatible?
@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
By the way, the data I'm collecting consists of Ruby method arguments. Elements in the list can be strings, numbers, hashes or lists.