Elasticsearch create index example
We have started using elasticsearch for indexing data to provide fast search for our webapps. It is a fantastic piece of software, but documentation is a little on the sparse side at the moment. After much learning and trial and error, here is the request we ended up sending with curl to create out index. Our index includes two types, person and company and some custom mappings. We thought it might be helpful for others trying to get started:
curl -XPOST localhost:9200/richtest2 -d '{ "settings": { "number_of_shards": 5, "number_of_replicas": 2, "analysis": { "filter": { "jnr_ngram_filter": { "type": "edgeNGram", "side": "front", "min_gram": 1, "max_gram": 25 } }, "analyzer": { "jnr_autocomplete_index_analyzer": { "tokenizer": "icu_tokenizer", "filter": ["icu_folding","jnr_ngram_filter"] }, "jnr_autocomplete_search_analyzer": { "tokenizer": "icu_tokenizer", "filter": "icu_folding" } } } }, "mappings": { "person": { "_source": { "enabled": true }, "properties": { "fullname": { "index_name" : "name", "type" : "multi_field", "fields" : { "autocomplete" : { "type" : "string", "index" : "analyzed", "index_analyzer": "jnr_autocomplete_index_analyzer", "search_analyzer": "jnr_autocomplete_search_analyzer" }, "name" : { "type" : "string", "index" : "not_analyzed" } } }, "city": { "type": "string", "index": "not_analyzed", "index_name" : "city" }, "user_tags": { "type": "string", "index": "not_analyzed", "index_name" : "user_tag" } } }, "company": { "_source": { "enabled": true }, "properties": { "com_name": { "index_name" : "name", "type" : "multi_field", "fields" : { "autocomplete" : { "type" : "string", "index" : "analyzed", "index_analyzer": "jnr_autocomplete_index_analyzer", "search_analyzer": "jnr_autocomplete_search_analyzer" }, "name" : { "type" : "string", "index" : "not_analyzed" } } }, "city": { "type": "string", "index": "not_analyzed", "index_name" : "city" }, "industry": { "type": "string", "index": "not_analyzed", "index_name" : "industry" }, "user_tags": { "type": "string", "index": "not_analyzed", "index_name" : "user_tag" } } } } }'read more
Get In Touch
It would be great to hear from you.
Please email us at [email protected] if you would like to get in touch. Alterntaively, select Contact from the menu at the top of this page.
read moreNew Website
Welcome to the new website for Open Aspect.
We will be filling this blog with bits and bobs related to Java, Agile, Spring,PHP and all other things Open Aspect related in due course.
In the meantime please get in touch by emailing [email protected]
read more