-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Query, what's wrong?
PostPosted: Thu Apr 17, 2008 8:28 am 
Newbie

Joined: Mon Apr 14, 2008 7:44 am
Posts: 4
Code:

        session = HibernateUtil.getSessionFactory().openSession();
       
        FullTextSession fullTextSession = Search.createFullTextSession(session);
        Transaction tx = fullTextSession.beginTransaction();
       
        //
        List<Video> lst = session.createQuery("from Video as video").list();
        for (Video vid : lst) {
            fullTextSession.index(vid);
        }
       
        MultiFieldQueryParser parser = new MultiFieldQueryParser( new String[]{"Year"},
        new StandardAnalyzer());
       
       
       
        org.apache.lucene.search.Query query;
        org.hibernate.Query hibQuery = null;
        try {
            query = (org.apache.lucene.search.Query)parser.parse( "2003" );
            hibQuery = fullTextSession.createFullTextQuery( query, Video.class );
        } catch (ParseException e) {
           
            e.printStackTrace();
        }
        List result = hibQuery.list();

        tx.commit();
       
        if (session != null) {
            session.close();
        }



result = 0;
What is wrong?
Data Base has 11 records, 3 from them is 2003 year


Top
 Profile  
 
 Post subject: Re: Query, what's wrong?
PostPosted: Thu Apr 17, 2008 10:49 am 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
What version of lucene do you use? I ever found same error if I find text that contains number like 2003 even thought it's string


Top
 Profile  
 
 Post subject: Re: Query, what's wrong?
PostPosted: Thu Apr 17, 2008 10:56 am 
Newbie

Joined: Mon Apr 14, 2008 7:44 am
Posts: 4
SIau_Tie wrote:
What version of lucene do you use? I ever found same error if I find text that contains number like 2003 even thought it's string


lucene-core-2.3.0
this code run without any erorrs. But result always = 0. May be problem is in other place?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.