my dog learned polymorphism*
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

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate search - indexes not being generated" Watch "Hibernate search - indexes not being generated" New topic

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.


Free Mock tests Interview questions
David Newton

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

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=""
value="" />
<property name="" value="e:\search" />

My eo class looks like below:
@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, {

private static final long serialVersionUID = 1L;

private TestCategoryEO testCategoryEO;
private SkillUserProfileEO guruEO;

Test test;

public Test getTest(){
return this.test;

public void setTest(Test test){

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

public TestEO(Test test) {

@GeneratedValue(strategy = GenerationType.IDENTITY)
public Integer getTestId() {
return test.getTestId();

public void setTestId(Integer 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) {

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

public void setTestDesc(String 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()); 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);
tests = new ArrayList<TestVO>();
for (TestEO testeo : result) {
TestVO test = (TestVO) testeo.getTest();

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.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60071

Please UseCodeTags

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Hibernate search - indexes not being generated
Similar Threads
Performace optimisation
Designing a multiple Join query
Database errors and Hibernate
Middlegen -Hibernate - use sequences for primary key
Hibernate create tables,column order and indexes