Skip to content

Instantly share code, notes, and snippets.

@jprante
Created November 16, 2012 19:46
Show Gist options
  • Save jprante/4090274 to your computer and use it in GitHub Desktop.
Save jprante/4090274 to your computer and use it in GitHub Desktop.
Magic Mapping ?
# value-style before object-style => "auto upgrade"
curl -XDELETE 'http://localhost:9200/test'
curl -XPUT 'localhost:9200/test/test/1' -d '
{
"obj" : "value"
}
'
curl -XGET 'localhost:9200/test/_refresh'
curl -XPUT 'localhost:9200/test/test/2' -d '
{
"obj" : { "key" : "value" }
}
'
curl -XGET 'localhost:9200/test/_refresh'
# 2 hits for '*'
curl -XGET 'localhost:9200/test/_search?q=*&pretty=1'
# 1 hit for 'obj'
curl -XGET 'localhost:9200/test/_search?q=obj:*&pretty=1'
# 0 hit for 'key'
curl -XGET 'localhost:9200/test/_search?q=key:*&pretty=1'
# object-style before value-style => MapperParsingException
curl -XDELETE 'http://localhost:9200/test'
curl -XPUT 'localhost:9200/test/test/2' -d '
{
"obj" : { "key" : "value" }
}
'
curl -XGET 'localhost:9200/test/_refresh'
curl -XPUT 'localhost:9200/test/test/1' -d '
{
"obj" : "value"
}
'
curl -XGET 'localhost:9200/test/_refresh'
# 1 hit
curl -XGET 'localhost:9200/test/_search?q=*&pretty=1'
# 0 hits for 'obj'
curl -XGET 'localhost:9200/test/_search?q=obj:*&pretty=1'
# 1 hit for 'key'
curl -XGET 'localhost:9200/test/_search?q=key:*&pretty=1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment