Forked from karmi/elastic_search_ngram_analyzer_for_urls.sh
Created
December 21, 2012 14:31
-
-
Save pcdinh/4353161 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 -X DELETE localhost:9200/custom_analyzer_test | |
| curl -X PUT localhost:9200/custom_analyzer_test -d ' | |
| { | |
| "settings" : { | |
| "index" : { | |
| "number_of_shards" : 1, | |
| "number_of_replicas" : 0, | |
| "analysis" : { | |
| "analyzer" : { | |
| "url_analyzer" : { | |
| "type" : "custom", | |
| "tokenizer" : "trigram", | |
| "filter" : ["stop", "url_filter", "lowercase"] | |
| } | |
| }, | |
| "tokenizer" : { | |
| "trigram" : { | |
| "type" : "nGram", | |
| "min_gram" : 1, | |
| "max_gram" : 5 | |
| } | |
| }, | |
| "filter" : { | |
| "url_filter" : { | |
| "type" : "stop", | |
| "stopwords" : ["http", "https", ":", "/", ".", "html"] | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "mappings": { | |
| "url": { | |
| "properties": { | |
| "url": { | |
| "type": "string", | |
| "analyzer": "url_analyzer", | |
| "boost": 10 | |
| }, | |
| "title": { | |
| "type": "string", | |
| "analyzer": "snowball", | |
| "boost": 5 | |
| }, | |
| "description": { | |
| "type": "string", | |
| "analyzer": "snowball" | |
| }, | |
| "tags": { | |
| "type": "string", | |
| "analyzer": "keyword" | |
| } | |
| } | |
| } | |
| } | |
| } | |
| ' | |
| curl -X POST "http://localhost:9200/custom_analyzer_test/url?refresh=true" -d ' | |
| { | |
| "url" : "http://www.euruko2011.org", | |
| "title" : "EURUKO 2011", | |
| "description" : "The greatest Ruby conference in Europe!", | |
| "tags" : ["ruby", "conference"] | |
| }' | |
| # curl "http://localhost:9200/custom_analyzer_test/_analyze?text=http://euruko2011.org/speakers.html&analyzer=url_analyzer" | |
| curl "http://localhost:9200/custom_analyzer_test/_search?q=url:peak" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment