# ======================================== # 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