Reputation: 543
Im trying to migrate a project thats using lucene to elasticsearch.
Im using:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.1.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>5.11.1.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-elasticsearch</artifactId>
<version>5.11.8.Final</version>
</dependency>
Elastic search version is: 5.6.16
Server Wildfly 15
The persistence.xml is configured like this:
<property name="hibernate.search.default.elasticsearch.host" value="http://elasticsearch:9200"/>
<property name="hibernate.search.default.elasticsearch.username" value="elastic"/>
<property name="hibernate.search.default.elasticsearch.password" value="changeme"/>
<property name="hibernate.search.default.elasticsearch.index_schema_management_strategy" value="drop-and-create"/>
When I try to deploy the application I get this error:
app-sgrecweb_1 | 12:31:35,179 WARN [org.hibernate.search.elasticsearch.client.impl.ServerUris] (MSC service thread 1-6) HSEARCH400073: Hibernate Search will connect to Elasticsearch server 'http://elasticsearch:9200' with authentication over plain HTTP (not HTTPS). The password will be sent in clear text over the network.
app-sgrecweb_1 | 12:31:35,501 WARN [org.hibernate.search.indexes.impl.LuceneEmbeddedIndexFamilyImpl] (MSC service thread 1-6) HSEARCH000075: Configuration setting hibernate.search.lucene_version was not specified: using LUCENE_CURRENT.
app-sgrecweb_1 | 12:32:32,251 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service jboss.deployment.unit."SGREC-ear-0.1.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."SGREC-ear-0.1.ear".WeldStartService: Failed to start service
app-sgrecweb_1 | at [email protected]//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1730)
app-sgrecweb_1 | at [email protected]//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1558)
app-sgrecweb_1 | at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
app-sgrecweb_1 | at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
app-sgrecweb_1 | at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
app-sgrecweb_1 | at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
app-sgrecweb_1 | at java.base/java.lang.Thread.run(Thread.java:834)
app-sgrecweb_1 | Caused by: org.jboss.weld.exceptions.DeploymentException: HSEARCH400007: Elasticsearch request failed.
app-sgrecweb_1 | Request: GET /_cluster/health/uy.gob.sgrec.entities.sslibroactanacimiento with parameters {wait_for_status=green, timeout=10000ms}
app-sgrecweb_1 | Response: 408 'Request Timeout' with body
app-sgrecweb_1 | {
app-sgrecweb_1 | "cluster_name": "docker-cluster",
app-sgrecweb_1 | "status": "yellow",
app-sgrecweb_1 | "timed_out": true,
app-sgrecweb_1 | "number_of_nodes": 1,
app-sgrecweb_1 | "number_of_data_nodes": 1,
app-sgrecweb_1 | "active_primary_shards": 5,
app-sgrecweb_1 | "active_shards": 5,
app-sgrecweb_1 | "relocating_shards": 0,
app-sgrecweb_1 | "initializing_shards": 0,
app-sgrecweb_1 | "unassigned_shards": 5,
app-sgrecweb_1 | "delayed_unassigned_shards": 0,
app-sgrecweb_1 | "number_of_pending_tasks": 0,
app-sgrecweb_1 | "number_of_in_flight_fetch": 0,
app-sgrecweb_1 | "task_max_waiting_in_queue_millis": 0,
app-sgrecweb_1 | "active_shards_percent_as_number": 50.0
app-sgrecweb_1 | }
app-sgrecweb_1 |
app-sgrecweb_1 | at [email protected]//org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:38)
app-sgrecweb_1 | at [email protected]//org.jboss.weld.bootstrap.events.AfterDeploymentValidationImpl.fire(AfterDeploymentValidationImpl.java:28)
app-sgrecweb_1 | at [email protected]//org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:499)
app-sgrecweb_1 | at [email protected]//org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:93)
app-sgrecweb_1 | at [email protected]//org.jboss.as.weld.WeldStartService.start(WeldStartService.java:98)
app-sgrecweb_1 | at [email protected]//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1738)
app-sgrecweb_1 | at [email protected]//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1700)
app-sgrecweb_1 | ... 6 more
So the problem here is I dont know if I have to populate elasticsearch before start deploying the aplication or elasticsearch is supouse to get populated automatic when I deploy. I already have data in a mysql database and the entities of the application are correctly defined (with lucene they use to work). Something is missing and I dont know what
Upvotes: 0
Views: 492
Reputation: 9977
The error you are getting is unrelated to your question.
You are getting this error because the Elasticsearch cluster has status yellow
, which basically means there aren't enough nodes to replicate your indexes. If you only intend to use one node, then that's fine and you should tell Hibernate Search that the status yellow
is fine for you via a configuration property:
hibernate.search.default.elasticsearch.required_index_status yellow
Regarding your question about how to populate Elasticsearch... it's the same as Lucene. Hibernate Search won't do it on startup, because that can take significant time and resources. You need to trigger what is called "mass indexing" yourself, but the indexing itself is automated. See https://docs.jboss.org/hibernate/search/5.11/reference/en-US/html_single/#search-batchindex-massindexer
Upvotes: 2