java - Hibernate Search not indexing items from database -
i'm trying integrate hibernate search in application. rough summary of needs done:
- spring batch reads out xml file , persists objects database. done de jdbcbatchitemwriter. not hibernateitemwriter because of slow performance.
- after items inserted build hibernate search/lucene index.
the problem in last step. nothing being indexed.
the setup follows:
there joblistener index data in database so:
session session = sessionfactory .withoptions() .opensession(); fulltextsession fulltextsession = search.getfulltextsession(session); try { fulltextsession.createindexer().startandwait(); } catch (interruptedexception e) { e.printstacktrace(); }
but when check index luke can't find records in it. guess has transactions can't figure out how make work.
this persistence configuration:
@bean public entitymanagerfactory entitymanagerfactory() { hibernatejpavendoradapter vendoradapter = new hibernatejpavendoradapter(); localcontainerentitymanagerfactorybean entitymanagerfactorybean = new localcontainerentitymanagerfactorybean(); entitymanagerfactorybean.setpackagestoscan("xxx.data.domain"); entitymanagerfactorybean.setjpavendoradapter(vendoradapter); entitymanagerfactorybean.setdatasource(datasource()); entitymanagerfactorybean.getjpapropertymap().putall(jpaproperties()); entitymanagerfactorybean.afterpropertiesset(); return entitymanagerfactorybean.getobject(); } @bean public fulltextentitymanager fulltextentitymanager(entitymanager entitymanagerfactory) throws interruptedexception { fulltextentitymanager fulltextentitymanager = search.getfulltextentitymanager(entitymanagerfactory); fulltextentitymanager.createindexer().startandwait(); return fulltextentitymanager; } private map<string, string> jpaproperties() { map<string, string> jpaproperties = new hashmap<string, string>(); jpaproperties.put("hibernate.dialect", "org.hibernate.dialect.oracledialect"); jpaproperties.put("hibernate.search.default.directory_provider", "filesystem"); jpaproperties.put("hibernate.search.default.indexbase", "/tmp/lucene/indexes"); jpaproperties.put("hibernate.search.indexing_strategy", "manual"); return jpaproperties; } @bean public sessionfactory sessionfactory(datasource datasource) throws ioexception { localsessionfactorybean localsessionfactorybean = new localsessionfactorybean(); localsessionfactorybean.setdatasource(datasource); localsessionfactorybean.setpackagestoscan("xxx.data.domain"); localsessionfactorybean.afterpropertiesset(); return localsessionfactorybean.getobject(); }
entity indexed:
@entity @table(name = "my_table") @indexed public class entryentity { public static final string sequence_name = "seq_my_table"; @id @generatedvalue(strategy = generationtype.sequence, generator = sequence_name) @sequencegenerator(name = sequence_name, sequencename = sequence_name, allocationsize = 1) @column(name = "id") private long id; @column(name = "entry_id") @field(index = index.yes, analyze = analyze.no, store = store.yes) private string entryidentifier; @column @field(index = index.yes, analyze = analyze.no, store = store.yes) private string value; public string getvalue() { return value; } public void setvalue(string value) { this.value = value; } }
i think problem defining search properties in jpaproperties processed entity manager. when call mass indexer, however, using plain session. in case jpa properties not picked up. guess there index directory created relative start jvm. should work entitymanager
. there org.hibernate.search.jpa.search
allows hold of fulltextentitymanager
.
Comments
Post a Comment