Skip to content

Instantly share code, notes, and snippets.

@derickson
Created April 23, 2015 15:44
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 derickson/61d66ed7d6a911db9cf0 to your computer and use it in GitHub Desktop.
Save derickson/61d66ed7d6a911db9cf0 to your computer and use it in GitHub Desktop.
DELETE /storedvsunstoredtest
## notice I disable the _all text index and the index: no setting on field2
PUT /storedvsunstoredtest
{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 3
},
"mappings": {
"testType": {
"_all" : {"enabled" : false},
"properties": {
"field1": {
"type": "string",
"index": "not_analyzed",
"store": false
},
"field2": {
"type": "string",
"index": "no",
"store": false
}
}
}
}
}
## bulk index two documents
PUT /storedvsunstoredtest/testType/_bulk
{ index: {"_id" : "user9999999999"}}
{ "field1": "abcdef", "field2": "ghijkl" }
{ index: {"_id" : "user8888888888"}}
{ "field1": "mnopqr", "field2": "stuvwx" }
## Notice both fields 1 and 2 are present when retrieved by id
GET /storedvsunstoredtest/testType/user9999999999
## Notice both fields 1 and 2are present with a blank search
GET /storedvsunstoredtest/testType/_search
## You can do a retrieval by field1
GET /storedvsunstoredtest/testType/_search
{
"query": {
"filtered": {
"filter": {
"term": {
"field1": "mnopqr"
}
}
}
}
}
## But doing a retrieval by field 2 fails because we told it not to index the same way inside elasticsearch.
GET /storedvsunstoredtest/testType/_search
{
"query": {
"filtered": {
"filter": {
"term": {
"field2": "ghijkl"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment