title: Initial indexation in Hibernate Search with Elasticsearch crashes
body: <p>I'm trying to add Hibernate Search's Elasticsearch implementation to an existing project.</p>
  
  <p>Everything seems to be okay, my updated and new entities are indexed to Elastic, but when I try to index existing data into Elasticsearch (using the snipped provided in documentation), I've got an error and the whole application crashes.</p>
  
  <p><strong>The indexation code</strong></p>
  
  <pre><code>FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(JPA.em());
  fullTextEntityManager.createIndexer().startAndWait();
  </code></pre>
  
  <p><strong>Error trace</strong></p>
  
  <pre><code>[error] o.h.s.e.i.LogErrorHandler - HSEARCH000058: Exception occurred org.hibernate.search.exception.SearchException: HSEARCH400007: Elasticsearch request failed.
   Request:
  ========
  Operation: DeleteByQuery
  URI:models.project.project/models.project.Project/_query
  Data:
  { "query" : { "constant_score" : { "filter" : { "match_all" : { } } } } }
  Response:
  =========
  Status: 404
  Error message: 404 Not Found
  Cluster name: null
  Cluster status: null
  
  
  Primary Failure:
          Entity models.project.Project  Id null  Work Type  org.hibernate.search.backend.PurgeAllLuceneWork
  Subsequent failures:
          Entity models.project.Project  Id null  Work Type  org.hibernate.search.backend.PurgeAllLuceneWork
  
  org.hibernate.search.exception.SearchException: HSEARCH400007: Elasticsearch request failed.
   Request:
  ========
  Operation: DeleteByQuery
  URI:models.project.project/models.project.Project/_query
  Data:
  { "query" : { "constant_score" : { "filter" : { "match_all" : { } } } } }
  Response:
  =========
  Status: 404
  Error message: 404 Not Found
  Cluster name: null
  Cluster status: null
  
  
          at org.hibernate.search.elasticsearch.client.impl.JestClient.executeRequest(JestClient.java:175)
          at org.hibernate.search.elasticsearch.client.impl.JestClient.executeRequest(JestClient.java:161)
          at org.hibernate.search.elasticsearch.client.impl.SingleRequest.doExecute(SingleRequest.java:42)
          at org.hibernate.search.elasticsearch.client.impl.SingleRequest.execute(SingleRequest.java:37)
          at org.hibernate.search.elasticsearch.client.impl.BackendRequestProcessor.doExecute(BackendRequestProcessor.java:106)
          at org.hibernate.search.elasticsearch.client.impl.BackendRequestProcessor.executeSync(BackendRequestProcessor.java:76)
          at org.hibernate.search.elasticsearch.impl.ElasticsearchIndexManager.performOperations(ElasticsearchIndexManager.java:406)
          at org.hibernate.search.backend.impl.LocalBackendQueueProcessor.applyWork(LocalBackendQueueProcessor.java:38)
          at org.hibernate.search.backend.impl.WorkQueuePerIndexSplitter.commitOperations(WorkQueuePerIndexSplitter.java:46)
          at org.hibernate.search.backend.impl.batch.DefaultBatchBackend.sendWorkToShards(DefaultBatchBackend.java:79)
  Uncaught error from thread [application-akka.actor.default-dispatcher-17] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[application]
  java.lang.NoSuchMethodError: org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.getIdentifierName()Ljava/lang/String;
          at org.hibernate.search.batchindexing.impl.BatchIndexingWorkspace.&lt;init&gt;(BatchIndexingWorkspace.java:88)
          at org.hibernate.search.batchindexing.impl.BatchCoordinator.doBatchWork(BatchCoordinator.java:131)
  [error] a.a.ActorSystemImpl - Uncaught error from thread [application-akka.actor.default-dispatcher-17] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled
          at org.hibernate.search.batchindexing.impl.BatchCoordinator.runWithErrorHandler(BatchCoordinator.java:97)
          at org.hibernate.search.batchindexing.impl.ErrorHandledRunnable.run(ErrorHandledRunnable.java:32)me()Ljava/lang/String;
  
          at org.hibernate.search.batchindexing.impl.MassIndexerImpl.startAndWait(MassIndexerImpl.java:213)
          at org.hibernate.search.batchindexing.impl.BatchIndexingWorkspace.&lt;init&gt;(BatchIndexingWorkspace.java:88)
          at org.hibernate.search.batchindexing.impl.BatchCoordinator.doBatchWork(BatchCoordinator.java:131)
          at models.project.Project.reindex(Project.java:253)
          at org.hibernate.search.batchindexing.impl.BatchCoordinator.runWithErrorHandler(BatchCoordinator.java:97)
          at controllers.ProjectController.reindex(ProjectController.java:80)
          at org.hibernate.search.batchindexing.impl.ErrorHandledRunnable.run(ErrorHandledRunnable.java:32)
          at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$12$$anonfun$apply$12.apply(Routes.scala:967)
          at org.hibernate.search.batchindexing.impl.MassIndexerImpl.startAndWait(MassIndexerImpl.java:213)
          at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$12$$anonfun$apply$12.apply(Routes.scala:967)
          at models.project.Project.reindex(Project.java:253)
          at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:157)
          at controllers.ProjectController.reindex(ProjectController.java:80)
          at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$12$$anonfun$apply$12.apply(Routes.scala:967)
          at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:156)
          at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$12$$anonfun$apply$12.apply(Routes.scala:967)
          at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$14$$anon$3$$anon$1.invocation(HandlerInvoker.scala:13 at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:157)
  6)
          at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:73)
          at play.http.HttpRequestHandler$1.call(HttpRequestHandler.java:54)
          at play.db.jpa.TransactionalAction.lambda$call$4(TransactionalAction.java:28)
          at play.db.jpa.DefaultJPAApi.lambda$withTransaction$3(DefaultJPAApi.java:196)
          at play.db.jpa.DefaultJPAApi.withTransaction(DefaultJPAApi.java:137)
          at play.db.jpa.DefaultJPAApi.withTransaction(DefaultJPAApi.java:195)
          at play.db.jpa.TransactionalAction.call(TransactionalAction.java:25)
          at security.CheckAction.lambda$call$0(CheckAction.java:47)
          at play.db.jpa.DefaultJPAApi.withTransaction(DefaultJPAApi.java:137)
          at play.db.jpa.DefaultJPAApi.withTransaction(DefaultJPAApi.java:95)
          at security.CheckAction.call(CheckAction.java:41)
          at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:108)
          at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:108)
          at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
          at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
          at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:56)
          at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:70)
          at play.core.j.HttpExecutionContext.execute(HttpExecutionContext.scala:48)
          at scala.concurrent.impl.Future$.apply(Future.scala:31)
          at scala.concurrent.Future$.apply(Future.scala:492)
          at play.core.j.JavaAction.apply(JavaAction.scala:108)
          at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:112)
          at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:112)
          at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
          at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:111)
          at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:110)
          at scala.Option.map(Option.scala:146)
          at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:110)
          at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:103)
          at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
          at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:249)
          at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
          at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
          at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:91)
          at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
          at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
          at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72)
          at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:90)
          at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39)
          at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:409)
          at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
          at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
          at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
          at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
  </code></pre>
  
  <p><strong>persistence.xml</strong></p>
  
  <pre><code>&lt;persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
           version="2.1"&gt;
  
  &lt;persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL"&gt;
      &lt;provider&gt;org.hibernate.jpa.HibernatePersistenceProvider&lt;/provider&gt;
      &lt;non-jta-data-source&gt;DefaultDS&lt;/non-jta-data-source&gt;
      &lt;properties&gt;
          &lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL9Dialect"/&gt;
          &lt;property name="hibernate.hbm2ddl.auto" value=""/&gt;
          &lt;property name="hibernate.connection.autocommit" value="true" /&gt;
          &lt;property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.DefaultComponentSafeNamingStrategy"/&gt;
          &lt;property name="hibernate.show_sql" value="false" /&gt;
          &lt;property name="hibernate.ejb.interceptor" value="history.HistoryInterceptor" /&gt;
  
          &lt;property name="hibernate.search.elasticsearch.host" value="http://localhost:9200" /&gt;
          &lt;property name="hibernate.search.default.indexmanager" value="elasticsearch" /&gt;
          &lt;property name="hibernate.search.index_management_strategy" value="CREATE" /&gt;
  
  
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p></p>
  
  <p>Any idea how to index initial data without this error?</p>
  
  <p>Thanks !</p>