You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Babak Bastan <ba...@gmail.com> on 2013/08/26 13:43:32 UTC

Lucene index files are empty

I want to umplement full text search using Lucene and Hibernate search. As
I understand, Lucene creats two files. These two files should be contain
some text data, but my index files are empty ( I open these two files with
Luke)

[image: Inline image 1]
here is my code:

@Entity@Indexed@Table(name="Users")@GenericGenerator(name="mongodb_uuidgg",strategy
= "uuid2")public class User implements Serializable{
    private static final long serialVersionUID=1L;
    @DocumentId
    @Id
    @GeneratedValue(generator="mongodb_uuidgg")
  //  @Column(name="id")
   @Field(index = Index.YES,analyze = Analyze.YES,store = Store.YES)
    private String  id;

    @Column(name="City")
    @Field(index = Index.YES,analyze = Analyze.YES,store = Store.YES)
    private String city;

    @Column(name="UserID")
    @NumericField
    @Field(index = Index.YES,analyze = Analyze.NO,store = Store.YES)
    private int IdU

and in DAO I have this block of code:

OgmConfiguration cfgogm=new OgmConfiguration();
        cfgogm.configure("hibernate.cfg.xml");
        serviceregistry=new
ServiceRegistryBuilder().applySettings(cfgogm.getProperties()).buildServiceRegistry();
        sessionfactory=cfgogm.buildSessionFactory(serviceregistry);


        sessionfactory.openSession();
        FullTextSession fulltextsession=
Search.getFullTextSession(sessionfactory.getCurrentSession());
        QueryBuilder
querybuilder=fulltextsession.getSearchFactory().buildQueryBuilder().forEntity(User.class).get();
        org.apache.lucene.search.Query
lucenequery=querybuilder.keyword().onField("IdU").matching(new
Integer(87709)).createQuery();

        org.hibernate.search.FullTextQuery
fulltextquery=fulltextsession.createFullTextQuery(
lucenequery,User.class );
        fulltextquery.initializeObjectsWith(ObjectLookupMethod.SKIP,
DatabaseRetrievalMethod.FIND_BY_ID);
        List result=fulltextquery.list();
        System.out.println(result.size());

could you please say me, what is my mistake?