Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7943015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:08:53+00:00 2026-06-04T00:08:53+00:00

I built an example project for hibernate search and it works fine without any

  • 0

I built an example project for hibernate search and it works fine without any exception but when I search a string that I have some objects with that string, it returns empty. I don’t know what should I do!!! Can somebody help me…
Project is maven based and I use hibernate annotation both for hibernate and hibernate search.
Here is my hibernate.cfg.xml file:

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">
            jdbc:mysql://localhost:3306/eprnews
        </property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">***</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.show_sql">true</property>
        <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
        <!-- 
        <property name="hibernate.hbm2ddl.auto">create-drop</property>

        Hibernate Search --> 
        <!-- org.hibernate.search.store.FSDirectoryProvider --> 
        <!-- org.hibernate.search.store.RAMDirectoryProvider for test -->
        <!-- 
        <property name="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</property>
         -->
        <property name="hibernate.search.default.directory_provider">filesystem</property>
        <property name="hibernate.search.default.indexBase">./indexes</property>
        <!-- 
         -->
        <property name="hibernate.search.worker.execution">async</property>
        <property name="hibernate.search.default.optimizer.transaction_limit.max">100</property>

        <!-- Mapped classes -->
        <mapping class="net.leemoo.test.entity.NewsEntity"/>
    </session-factory>
</hibernate-configuration>

and here is my entity:

@Entity
@Table(name="news")
@Indexed
@AnalyzerDef(
            name = "PersianAnal",
            charFilters = @CharFilterDef(factory = PersianCharFilterFactory.class),
            tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
            filters={
                        @TokenFilterDef(factory = ArabicNormalizationFilterFactory.class),
                        @TokenFilterDef(factory = PersianNormalizationFilterFactory.class)
                    }
            )
public class NewsEntity {

    @Id
    @GeneratedValue
    private Long id;

    @Field
    @Analyzer(definition="PersianAnal")
    private String title;

    @Field
    @Analyzer(definition="PersianAnal")
    private String newsAbstract;

    @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO)
    @Analyzer(definition="PersianAnal")
    private String content;

    @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO)
    @DateBridge(resolution=Resolution.DAY)
    private Date creationDate;

    @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO)
    @DateBridge(resolution=Resolution.DAY)
    private Date modifiedDate;

    private Integer viewsCounter;

    @Field
    @Analyzer(definition="PersianAnal")
    private String keywords;

    private Boolean jqueryNews;

    private Boolean photoNews;
        and setters and getters...

and this is the code that i use for searching:

Session session = HibernateUtil.getSessionFactory().openSession();

        session.beginTransaction();
        FullTextSession fullTextSession = Search.getFullTextSession(session);
        try {
//          fullTextSession.createIndexer().startAndWait();
            QueryBuilder gb = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(NewsEntity.class).get();
            Query query = gb.keyword().
                onFields("title", "newsAbstract", "content").
                matching("test").createQuery();
            org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(query, NewsEntity.class);
            List<NewsEntity> result = (List<NewsEntity>)hibQuery.list();
            System.out.println(result.size());
        } catch (Exception e) {
//          e.printStackTrace();
        }

        session.getTransaction().commit();
        session.close();

What should I do? Please help me….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:08:55+00:00Added an answer on June 4, 2026 at 12:08 am

    I think I made a silly mistake in that I commented my index creator in last code phrase. I should run it once in the beginning for indexes to be created. I’m sorry again that I took your time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have 3 maven project (starto.commons,starto.hibernate,starto.server) that use some same dependencies and two of
In a project built with GNU Autotools, I have a script that needs to
I have a closed source project that is built on my open source framework.
The problem is that when projects are been built and produced normally without any
I tried to build vtkMFC project available in vtk-5.8.0\VTK\Examples\GUI\Win32\vtkMFC. When I built that I
Because of some limitations ( example ) in the built-in ActionScript 3 Dictionary class
Does anyone have a working example of a video player built using Qt phonon?
I'm looking for a built-in Matlab function that sums two polynomial. Example: p1(x) and
Does Boost Ranges have a built-in way to cout the elements easily, for example
I'm trying to build a Hibernate Criteria query to find entities that have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.