-->
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: Search not functioning properly
PostPosted: Thu Nov 18, 2010 2:58 am 
Newbie

Joined: Tue Nov 09, 2010 5:41 am
Posts: 2
hi,
I am some problems making my lucene search work

Following is the code
String[] fields = new String[] {"name","description","priority"};
String searchString = "name:" + crt.getSearchString() + " OR description:" + crt.getSearchString() + " OR priority:" + crt.getSearchString() + " AND project.id:" + projectId.toString();
org.apache.lucene.search.Query luceneQuery = null;
luceneQuery = parser.parse(searchString);
Query fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery, ABC.class, DEF.class, GHI.class, XYZ.class);
List entitylist = fullTextQuery.list();

Name and description are string properties and priority is a long property.
When I enter a search term for priority the above code works fine and I get the desired result, but if I search for name or description I do not get any result.
If I change the searchString by removing the priority from the search then I get the desired results for both name and description
String searchString = "name:" + crt.getSearchString() + " OR description:" + crt.getSearchString() + " AND project.id:" + projectId.toString();

I am not sure why this would happen. Any ideas?

Thanks,
Cherian


Top
 Profile  
 
 Post subject: Re: Search not functioning properly
PostPosted: Thu Nov 18, 2010 9:56 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Are you not missing grouping brackets - something like (name OR description OR priority) AND projectId?
See also Lucene query syntax - http://lucene.apache.org/java/3_0_2/que ... yntax.html

--Hardy


Top
 Profile  
 
 Post subject: Re: Search not functioning properly
PostPosted: Fri Nov 19, 2010 12:41 am 
Newbie

Joined: Tue Nov 09, 2010 5:41 am
Posts: 2
Than you Hardy the brackets solved the issue.
Cherian


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.