Skip to content

Instantly share code, notes, and snippets.

@kimchy
Created September 22, 2011 11:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimchy/1234581 to your computer and use it in GitHub Desktop.
Save kimchy/1234581 to your computer and use it in GitHub Desktop.
# Have an index created with "no_stopwords" analyzer
curl -XPUT 'http://localhost:9200/my_twitter1/' -d '
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis" : {
"analyzer" : {
"no_stopwords" : {
"type" : "standard",
"stopwords" : "_none_"
}
}
}
},
"mappings": {
"tweet" : {
"_all" : {"type" : "string", "null_value" : "na", "index" : "analyzed", "analyzer" : "no_stopwords"},
"properties" : {
"user" : {"type" : "string", "index" : "not_analyzed"},
"message" : {"type" : "string", "null_value" : "na", "index" : "analyzed", "analyzer" : "no_stopwords"},
"postDate" : {"type" : "date"}
}
}
}
}'
# But that can be annoying to set on each field, i.e. we want the no_stopword analyzer to be the default (and then we don't have to specify it in the mappings):
curl -XPUT 'http://localhost:9200/my_twitter1/' -d '
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis" : {
"analyzer" : {
"default" : {
"type" : "standard",
"stopwords" : "_none_"
}
}
}
},
"mappings": {
"tweet" : {
"_all" : {"type" : "string", "null_value" : "na", "index" : "analyzed"},
"properties" : {
"user" : {"type" : "string", "index" : "not_analyzed"},
"message" : {"type" : "string", "null_value" : "na", "index" : "analyzed"},
"postDate" : {"type" : "date"}
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment