Created
April 23, 2015 15:44
-
-
Save derickson/61d66ed7d6a911db9cf0 to your computer and use it in GitHub Desktop.
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
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