When the Hibernate Search session is initialized, org.hibernate.search.elasticsearch.impl.ElasticsearchIndexManager automatically constructs its index in Elasticsearch according to the annotations present on the entities in the index. It then sets its internal indexInitialized value to true. Any subsequent operations (like searches or indexing of new data) is therefore performed as if the index in Elasticsearch exists and is correct.
However, anyone can at any time drop the actual index manually in Elasticsearch by calling DELETE /<index_name> on the Elasticsearch instance. This results in either errors or incorrect behaviour, depending on the Elasticsearch auto_create_index setting (see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#index-creation)
If automatic index creation is ON in the Elasticsearch server (the default), then upon receiving a request to add data to an index which does not exist, Elasticsearch will simply create the index based on the data received. This means the index will not comply with any custom annotation details specified in the Hibernate objects (such as, for example, selecting a custom analyzer for a particular field). The index will also omit any fields which are present in the Hibernate entities but null or not present in the data submitted for indexing. This results in somewhat insidious behaviour where everything seems to be working since the index name is correct (and it may actually work for simple cases) but the actual index is not as specified in the entity annotations.
If automatic index creation is off, then adding new data simply fails with an HTTP 404 error (index not found) and Hibernate Search never attempts to recreate the index.
ElasticsearchIndexManager should handle the case when a request to add or search on an index results in a 404 by recreating the index as necessary. Alternatively, or perhaps even simply in addition, some mechanism should be provided for user applications to detect or handle this scenario by manually requesting recreation of an Elasticsearch index.