Skip to content

Instantly share code, notes, and snippets.

@redbeard
Created November 29, 2011 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redbeard/1403154 to your computer and use it in GitHub Desktop.
Save redbeard/1403154 to your computer and use it in GitHub Desktop.
Demonstrates a potential bug in elasticsearch's 'store' and 'enabled' mapping options
#!/bin/bash
curl -XDELETE 'http://localhost:9200/documents/'
echo ""
curl -XPUT 'http://localhost:9200/documents' -d '
{
"mappings": {
"document" : {
"_source" : { "enabled" : true },
"properties" : {
"content" : {"type" : "string", "store" : "yes"},
"ignored_string" : {"type" : "string", "store" : "no", "index": "no" },
"ignored_object" : {"type" : "object", "enabled": false, "store": "no", "index": "no" }
}
}
}
}'
echo ""
curl -X PUT "http://localhost:9200/documents/document/1" -d '
{
"content":"Hello world",
"ignored_string": "This should not be indexed or stored",
"ignored_object": { "description" : "This should not be indexed or stored" }
}'
echo ""
echo "Via get:"
curl -X GET "http://localhost:9200/documents/document/1"
echo ""
sleep 5
echo "Via search:"
curl -X GET "http://localhost:9200/documents/_search" -d '
{
"query":
{
"text":
{ "content": "Hello" }
}
}
'
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment