Is there any option to create some initial objects, e.g. indexes in ES? Similar task in RDMS world is usually done by DDL scripts to create tables, etc. Is there a similar practice for ES? Like before I place something into ES, I believe I should have an index created, right?
Strictly speaking, it's not needed.
However, best practices are to manually define the mapping for the documents you expect to index, to fully optimize them, or to plan for specific tokenizers, analyzers, or numeric types.
But, if you don't create that first, Elasticsearch's default behavior is to do its best guess to identify your fields. You can use this to your advantage. Let Elasticsearch create the initial "guess" mapping, then edit it to make a more "final" mapping. Delete the test index, and then create new ones with the mapping you created/edited.
Aaron, thank you for your clarification! it is very helpful, I am just starting with ES...
Based of your response, I see I still need to create mappings for index. I believe mappings define what type of documents can be stored in the index. Then I need to create mappings before I start adding documents into ES. So, it means I should have a kind of a script that first creates an index and then adds mappings. I can probably script it using curl and ES rest API and run it when my app get deployed to the application server/cloud. Correct me if I am wrong.
Do i really need those mappings? Will it impact performance if I use ES without mappings?
Not strictly speaking, no. Even if you're not using Logstash, the principle of how to create a mapping, or use Elasticsearch to generate a prototype mapping, and then edit it is described in this blog post.
To be clear: Elasticsearch does a phenomenal job of guessing what the mapping should look like without you having to do anything. You can always just go with this approach. It is when you want maximum performance that you should consider making a custom mapping. The easiest way to do that is to start with the "automatically" generated mapping, and edit to suit.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.