Forked from karmi/elastic_search_ngram_analyzer_for_urls.sh
Created
May 24, 2011 16:34
-
-
Save hukl/989073 to your computer and use it in GitHub Desktop.
NGram Analyzer in ElasticSearch
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 -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" : "lowercase", | |
"filter" : ["lowercase", "stop", "url_filter", "url_ngram"] | |
} | |
}, | |
"filter" : { | |
"url_filter" : { | |
"type" : "stop", | |
"stopwords" : ["http", "https", ":", "/", ".", "html"] | |
}, | |
"url_ngram" : { | |
"type" : "nGram" | |
} | |
} | |
} | |
} | |
}, | |
"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