Forked from fmpwizard/elastic_search_ngram_analyzer_for_urls.sh
Created
July 13, 2014 03:16
-
-
Save cheekybastard/974817b66c67c0e08c9c 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
# ======================================== | |
# Testing n-gram analysis in ElasticSearch | |
# ======================================== | |
curl -X DELETE localhost:9200/test | |
curl -X PUT localhost:9200/test -d ' | |
{ | |
"settings" : { | |
"index" : { | |
"analysis" : { | |
"analyzer" : { | |
"part_number_analyzer" : { | |
"type" : "custom", | |
"tokenizer" : "keyword", | |
"filter" : ["part_number_edgeNGram", "word_filter", "lowercase"] | |
} | |
},"filter" : { | |
"part_number_edgeNGram" : { | |
"type" : "edgeNGram", | |
"min_gram" : 4, | |
"max_gram" : 30, | |
"side" : "front" | |
},"lowercase" : { | |
"type" : "lowercase" | |
}, | |
"word_filter": { | |
"type": "word_delimiter", | |
"generate_word_parts" : "false", | |
"generate_number_parts" : "false", | |
"split_on_numerics" : "false", | |
"split_on_case_change" : "false", | |
"preserve_original" : "true" | |
} | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"main": { | |
"properties": { | |
"part_number": { | |
"type": "string", | |
"index_analyzer": "part_number_analyzer", | |
"search_analyzer": "keyword", | |
"boost": 10 | |
} | |
} | |
} | |
} | |
} | |
' | |
curl -X POST "http://localhost:9200/test/main" -d '{ "part_number" : "PA2829U" }' | |
curl -X POST "http://localhost:9200/test/main" -d '{ "part_number" : "5W298" }' | |
curl -X POST "http://localhost:9200/test/main" -d '{ "part_number" : "12345-78912345" }' | |
curl -X POST "http://localhost:9200/test/_refresh" | |
curl "http://localhost:9200/test/_analyze?text=PA2829U&analyzer=part_number_analyzer&pretty=true" | |
URLS=' | |
http://localhost:9200/test/_search?q=part_number:pa2829 | |
http://localhost:9200/test/_search?q=part_number:PA2829 | |
http://localhost:9200/test/_search?q=part_number:PA111 | |
http://localhost:9200/test/_search?q=part_number:5W29 | |
http://localhost:9200/test/_search?q=part_number:12345-78912345 | |
' | |
for url in ${URLS} | |
#for url in "nada" | |
do | |
echo; echo; echo ">>> ${url}" | |
if which open &> /dev/null; then | |
open "${url}&pretty=true" | |
fi | |
curl "${url}&pretty=true" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment