Skip to content

Instantly share code, notes, and snippets.

@ramseykhalaf
Created June 5, 2013 07:03
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 ramseykhalaf/5712106 to your computer and use it in GitHub Desktop.
Save ramseykhalaf/5712106 to your computer and use it in GitHub Desktop.
An example of a confusing mapping in elasticsearch.
curl -XDELETE http://localhost:27000/sandbox
curl -XPUT http://localhost:27000/sandbox -d '{
}'
curl -XPUT http://localhost:27000/sandbox/websites/_mapping -d '{
"websites" : {
"properties" : {
"tags" : {
"type" : "string"
},
"url": {
"type": "string",
"index": "no",
"include_in_all": "true"
}
}
}
}'
curl -XPUT http://localhost:27000/sandbox/websites/1?refresh=1 -d '{
"text": "sample text computer",
"url": "www.domain.com"
}'
curl -XGET http://localhost:27000/sandbox/_search
curl -XGET http://localhost:27000/sandbox/websites/_search -d '{
"query": {
"term": {
"_all": "www.domain.com"
}
}
}'
@ramseykhalaf
Copy link
Author

This will give a hit, the "include_in_all" means the string is run through the _all analyzer, which would be the standard one, unless you specify otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment