aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate search - indexes not being generated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate search - indexes not being generated" Watch "Hibernate search - indexes not being generated" New topic
Author

Hibernate search - indexes not being generated

Smitha H Rao
Ranch Hand

Joined: Oct 20, 2007
Posts: 50
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

Free Mock tests Interview questions
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You haven't provided much to go on--please TellTheDetails.
Smitha H Rao
Ranch Hand

Joined: Oct 20, 2007
Posts: 50
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

Joined: Jan 10, 2002
Posts: 61241
    
  66

Please UseCodeTags


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate search - indexes not being generated