Created
March 21, 2011 18:00
-
-
Save kimchy/879883 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
curl -XPUT localhost:9200/local -d '{ | |
"settings" : { | |
"analysis" : { | |
"analyzer" : { | |
"stem" : { | |
"tokenizer" : "standard", | |
"filter" : ["standard", "lowercase", "stop", "porter_stem"] | |
} | |
} | |
} | |
}, | |
"mappings" : { | |
"article" : { | |
"dynamic" : true, | |
"properties" : { | |
"title" : { | |
"type" : "string", | |
"analyzer" : "stem" | |
} | |
} | |
} | |
} | |
}' | |
# Sample Analysis | |
curl -XGET localhost:9200/local/_analyze?analyzer=stem -d '{Fight for your life}' | |
curl -XGET localhost:9200/local/_analyze?analyzer=stem -d '{Bruno fights Tyson tomorrow}' | |
# Index Data | |
curl -XPUT localhost:9200/local/article/1 -d'{"title": "Fight for your life"}' | |
curl -XPUT localhost:9200/local/article/2 -d'{"title": "Fighting for your life"}' | |
curl -XPUT localhost:9200/local/article/3 -d'{"title": "My dad fought a dog"}' | |
curl -XPUT localhost:9200/local/article/4 -d'{"title": "Bruno fights Tyson tomorrow"}' | |
# search on the title field, which is stemmed on index and search | |
curl -XGET localhost:9200/local/_search?q=title:fight | |
# searching on _all will not do anystemming, unless also configured on the mapping to be stemmed... | |
curl -XGET localhost:9200/local/_search?q=fight |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment