Beginner question about index creation with NEST


#1

I reading documentation about creating index using .NET client (NEST), and I wondering where (and when) is the right place to do that:

On server startup? Then, before attempt to create index I should check first if such index already exist, correct?


(Russ Cam) #2

Where you decide to create indices is going to be very application/use case dependent.

Assuming that you're working on a search use case where you will be explicitly controlling mappings, you'll create the index before indexing any documents into it, including the mapping in the index creation request.

It could well be that you create the index on startup, perhaps checking if the index exists first and if not, creating it. You may go further and also check that the mapping in the index conforms to the one that you expect (I haven't typically gone this far as mappings may change over time and outside of the application itself).

If this is also a search use case with a single index, I would recommend that your application uses an alias to refer to the index. In doing so, new versions of the search index can be created at any time (perhaps with refined mappings as you iterate on your search strategy) and then once you are happy with a new index, simply swap the alias over to point to that new index, the result being that your application will now be using the new index with zero downtime.


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.