Skip to content

Instantly share code, notes, and snippets.

@dadoonet
Created February 20, 2012 23:19
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 dadoonet/1872218 to your computer and use it in GitHub Desktop.
Save dadoonet/1872218 to your computer and use it in GitHub Desktop.
disabling source curl recreation
# Delete the index
curl -XDELETE http://localhost:9200/twitter
# Create the index
curl -XPUT http://localhost:9200/twitter
# Create the mapping using only fields
curl -XPOST http://localhost:9200/twitter/tweet/_mapping -d '{
"tweet" : {
"_source" : {"enabled" : false},
"properties" : {
"user" : {"type" : "string", "store" : "yes"},
"message" : {"type" : "string", "store" : "yes"}
}
}
}'
# Create the mapping using source
curl -XPOST http://localhost:9200/twitter/othertweet/_mapping -d '{
"othertweet" : {
"properties" : {
"user" : {"type" : "string"},
"message" : {"type" : "string"}
}
}
}'
# Indexing with fields
curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{
"user" : "dadoonet field",
"message" : "Elasticsearch rocks field"
}'
# Indexing with source
curl -XPUT http://localhost:9200/twitter/othertweet/1 -d '{
"user" : "dadoonet source",
"message" : "Elasticsearch rocks source"
}'
# Searching for all
curl -XPOST http://localhost:9200/_search?pretty=true -d '{
"query" : {
"match_all" : { }
}
}'
# Searching for specific fields
curl -XPOST http://localhost:9200/_search?pretty=true -d '{
"fields" : ["user", "message"],
"query" : {
"match_all" : { }
}
}'
# Searching for all fields (_source is not in *)
curl -XPOST http://localhost:9200/_search?pretty=true -d '{
"fields" : ["*"],
"query" : {
"match_all" : { }
}
}'
# _source works with 0.17.10 but not with 0.19.0.RC2
curl -XPOST http://localhost:9200/_search?pretty=true -d '{
"fields" : ["_source"],
"query" : {
"match_all" : { }
}
}'
# _source doesn't appear even with 0.17.10 nor 0.19.0.RC2
curl -XPOST http://localhost:9200/_search?pretty=true -d '{
"fields" : ["*", "_source"],
"query" : {
"match_all" : { }
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment