I am new to Hibernate search. But after all set up, I get blank list of object on every search. In the index directory, though I see segments and segments.gen files, they are just a 1 kb files (where my table is full of data). I think the indexes are not being generated for the table. Does anyone has any idea about it? Please help.
You haven't provided much to go on--please TellTheDetails.
Smitha H Rao
Ranch Hand
Joined: Oct 20, 2007
Posts: 50
posted
0
Hi,
I have integrated hibernate serach into an existing spring and hibernate web application. I have added following 2 in the persistence.xml files:
<property name="hibernate.search.default.directory_provider"
value="org.hibernate.search.store.FSDirectoryProvider" />
<property name="hibernate.search.default.indexBase" value="e:\search" />
My eo class looks like below:
@Entity
@Table(name="test")
@Indexed
@AnalyzerDef(name = "customanalyzer",
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = SnowballPorterFilterFactory.class,
params = {
@Parameter(name = "language", value = "English")
})
})
public class TestEO extends UpdateableEO implements Test,java.io.Serializable {
public void setTestDesc(String testDesc) {
test.setTestDesc(testDesc);
}
.....
The code I am using to do search is as follows:
String[] fields = new String[]{"testName","testDesc", "keywords"};
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
org.apache.lucene.search.Query query = parser.parse( strTest );
// wrap Lucene query in a javax.persistence.Query javax.persistence.Query persistenceQuery = testDAO.getFullTextEntityManager().createFullTextQuery(query, TestEO.class);
// execute search
System.out.println("created query::"+persistenceQuery.toString());
List<TestEO> result = persistenceQuery.getResultList();
System.out.println("result ::"+result);
if(result!=null){
tests = new ArrayList<TestVO>();
for (TestEO testeo : result) {
TestVO test = (TestVO) testeo.getTest();
test.setGuru(testeo.getGuruEO().getUserProfile());
test.setTestCategory(testeo.getTestCategoryEO().getTestCategory());
}
}
The problem is in the index directory, i. e in e/search I can see TestEO directory being created and inside that I see segments and segments.gen files, but they are just 1 kb files where my table is full of data.
Searching on any string shows blank List.. Please help me solving this.