Created
July 10, 2013 08:15
-
-
Save radu-gheorghe/5964376 to your computer and use it in GitHub Desktop.
Elasticsearch: If you create a mapping with the ID field pointing to a certain path, inserting two docs with the same ID should overwrite, instead of throwing an error. Unless you specify to "create" documents
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
#!/bin/bash | |
curl -XDELETE localhost:9200/test | |
curl -XPUT localhost:9200/test | |
curl -XPUT localhost:9200/test/test/_mapping -d '{ | |
"test": { | |
"_id": { | |
"path": "foo" | |
} | |
} | |
}' | |
echo | |
echo "should be OK" | |
curl -XPOST localhost:9200/test/test/ -d '{"foo": "bar"}' | |
echo | |
echo "should be OK again" | |
curl -XPOST localhost:9200/test/test/ -d '{"foo": "bar"}' | |
echo | |
echo '{ "index": { "_index": "test", "_type": "test"}} | |
{"foo": "bar"}' > /tmp/bla | |
echo | |
echo "bulks should be OK as well" | |
curl -XPOST localhost:9200/_bulk --data-binary @/tmp/bla | |
echo | |
echo | |
echo "This should fail, though" | |
curl -XPOST localhost:9200/test/test/?op_type=create -d '{"foo": "bar"}' | |
echo | |
echo "And bulk creates too" | |
echo '{ "create": { "_index": "test", "_type": "test"}} | |
{"foo": "bar"}' > /tmp/bla | |
curl -XPOST localhost:9200/_bulk --data-binary @/tmp/bla | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment