Last active
August 29, 2015 14:07
-
-
Save herrvonb/0a247aa7dfd0d155b418 to your computer and use it in GitHub Desktop.
Creating new elasticsearch index, with custom analyzer: stemming dutch compound words, finally run query
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
#!/bin/bash | |
curl -XDELETE localhost:9200/foo | |
curl -XPUT localhost:9200/foo -d '{ | |
"settings": { | |
"number_of_replicas": 0, | |
"number_of_shards": 1, | |
"analysis": { | |
"filter": { | |
"dutch_stemmer": { | |
"type": "dictionary_decompounder", | |
"word_list": [ | |
"koud", | |
"plaat", | |
"staal", | |
"fabriek" | |
] | |
}, | |
"snowball_nl": { | |
"type": "snowball", | |
"language": "dutch" | |
} | |
}, | |
"analyzer": { | |
"dutch": { | |
"tokenizer": "standard", | |
"filter": [ | |
"length", | |
"lowercase", | |
"asciifolding", | |
"dutch_stemmer", | |
"snowball_nl" | |
] | |
} | |
} | |
} | |
} | |
}' | |
curl -XPOST localhost:9200/foo/bar/_mapping -d '{ | |
"properties": { | |
"test": { | |
"type": "string", | |
"analyzer": "dutch" | |
} | |
} | |
}' | |
# adding some document | |
curl -XPOST localhost:9200/foo/bar/_bulk -d ' | |
{"index": {"_id":"1"}} | |
{"test": "ijskoud"} | |
{"index": {"_id":"2"}} | |
{"test": "plaatstaal"} | |
{"index": {"_id":"3"}} | |
{"test": "kristalfabriek"} | |
' | |
# dont search to early as es needs some time until docs a available | |
sleep 1 | |
printf "\nall documents:\n" | |
curl -XGET localhost:9200/foo/_search?pretty=true | |
printf "\nactive mapping\n" | |
curl -XGET localhost:9200/foo/_mapping?pretty=true | |
printf "\nsearch for plaat\n" | |
curl -XGET localhost:9200/foo/_search?pretty=true -d '{ | |
"query": { | |
"match": { | |
"test": "plaat" | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment