Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate search - indexes not being generated

 
Smitha H Rao
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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.

Thanks
Smitha
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You haven't provided much to go on--please TellTheDetails.
 
Smitha H Rao
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 {

private static final long serialVersionUID = 1L;

private TestCategoryEO testCategoryEO;
private SkillUserProfileEO guruEO;

@Transient
Test test;

@Transient
public Test getTest(){
return this.test;
}

public void setTest(Test test){
this.test=test;
}

public TestEO() {
this.test = new TestVO();
}

public TestEO(Test test) {
this.test=test;
}

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@DocumentId
@Column(name="test_id")
public Integer getTestId() {
return test.getTestId();
}

public void setTestId(Integer testSetId) {
test.setTestId(testSetId);
}

@Column(name="test_name", unique=false, nullable=true, insertable=true, updatable=true, length=45)
@Field(index=Index.TOKENIZED, store=Store.NO)
@Analyzer(definition = "customanalyzer")
public String getTestName() {
return test.getTestName();
}

public void setTestName(String testName) {
test.setTestName(testName);
}

@Column(name="test_desc")
@Field(index=Index.TOKENIZED, store=Store.NO)
@Analyzer(definition = "customanalyzer")
public String getTestDesc() {
return test.getTestDesc();
}

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.


Thanks
Smitha
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic