Wildfly Server Provisioning Elastic Search Integration

I'm interested in addition to would similar to evaluate the integration of Elasticsearch to hibernate-search. I'm using the Wildfly container, however, Wildfly's hibernate-search library is a flake outdated: 5.5.8. in addition to therefore I bespeak to detect a agency to outdate the jars in addition to that's what led me to WF's server-provisioning using characteristic pack which is good explained hither https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#updating-wildfly-hibernatesearch-versions

As stated yous bespeak to add together the lines below to your persistence.xml
<property name="jboss.as.jpa.providerModule" value="org.hibernate:5.3" /> <property name="wildfly.jpa.hibernate.search.module" value="org.hibernate.search.orm:5.10.3.Final" /> 

Then yous bespeak to practice a file named server-provisioning.xml inward your project's origin folder:

<server-provisioning xmlns="urn:wildfly:server-provisioning:1.1" copy-module-artifacts="true">     <feature-packs>          <feature-pack             groupId="org.hibernate"             artifactId="hibernate-search-jbossmodules-orm"             version="5.10.3.Final"/>          <feature-pack groupId="org.hibernate"    artifactId="hibernate-search-jbossmodules-elasticsearch" version="5.10.3.Final" />          <feature-pack             groupId="org.wildfly"             artifactId="wildfly-feature-pack"             version="13.0.0.Final" />      </feature-packs> </server-provisioning> 
And finally inward your pom.xml file add together the plugin below:
<plugin>     <groupId>org.wildfly.build</groupId>     <artifactId>wildfly-server-provisioning-maven-plugin</artifactId>     <version>1.2.6.Final</version>     <executions>         <execution>         <id>server-provisioning</id>         <goals>             <goal>build</goal>         </goals>         <phase>compile</phase>         <configuration>             <config-file>server-provisioning.xml</config-file>             <server-name>wildfly-with-updated-hibernate-search</server-name>         </configuration>         </execution>     </executions> </plugin> 
It should practice a novel folder inward your target's directory named wildfly-with-updated-hibernate-search. And yous should re-configure this server for your needs: datasource, mail, cache, etc. Make certain that it contains the scandalise files within modules folder. The setting inward a higher house copy-module-artifacts="true" should practice it, notice that inward the hibernate-search documentation, this belongings is non initialized. Thus, I spent merely about hours how to obtain the jars (I fifty-fifty downloaded merely about :-)).
It industrial plant for a basic requirement, but I soundless flora merely about errors though like:
Caused by: java.lang.NoClassDefFoundError: javax/persistence/TableGenerators 
Which should live solved yesteryear adding:
<dependency>  <groupId>javax.persistence</groupId>  <artifactId>javax.persistence-api</artifactId>  <version>2.2</version> </dependency> 

But that does non solve the trial in addition to therefore I added the -Dee8.preview.mode=true parameter in addition to that did the trick.

Well, yous may merely desire to aspect for the loose of Wildfly14.

Changes for Elasticsearch

In your projection dependency add:
 
<dependency>  <groupId>org.hibernate</groupId>  <artifactId>hibernate-search-elasticsearch</artifactId>  <version>5.10.3.Final</version> </dependency>  <dependency>  <groupId>org.elasticsearch</groupId>  <artifactId>elasticsearch</artifactId>  <version>6.2.3</version> </dependency> 

Make merely about youngster tweaks to persistence.xml
 
<property name="hibernate.search.default.indexmanager" value="elasticsearch" /> <property name="hibernate.search.default.elasticsearch.host" value="http://127.0.0.1:9200" /> <property name="hibernate.search.default.elasticsearch.index_schema_management_strategy" value="CREATE" />
 
Run elasticsearch inward docker https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html. Make certain that the condition of your elasticsearch server is green. See docker-compose.yml inward the projection mentioned below.

Run your application. You should live able to run across logs inward elasticsearch that verifieds the information posted.

You may desire to cheque the consummate code accessible at https://github.com/czetsuya/hibernate-search-demo. Switch to latest-hibernate-search branch.

Note:

  • There are iii errors amongst the elasticsearch integration related to JSON.
  • If yous desire to displace lucene, merely alter the configuration inward test-persistence.xml.


You may likewise desire to check:
Next
Previous
Click here for Comments

0 komentar:

Please comment if there are any that need to be asked.