-->
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.  [ 2 posts ] 
Author Message
 Post subject: Searching with optional parameters
PostPosted: Mon Jul 11, 2011 5:24 pm 
Newbie

Joined: Mon Jul 11, 2011 5:16 pm
Posts: 12
Hello,

I'm fairly new to Hibernate Search so this may be a very simple question. I attempted to search the web and the texts I am using to learn Hibernate Search but have been unable to find the solution I am looking for(to be honest I may just not be using the right terms in my search so feel free to provide links if the content exists already).

I am currently trying to implement a full text search in a web application that is used to keep track of a product catalog. As of now I have a basic search running that can search by manufacturer or product name. The issue I am running into is that the search is designed to allow the user to choose the fields they search by (for example a user could choose to search by product name or manufacture or both) as long as something is occupying both search fields results are returned.

However when I choose to search for only one of the fields (like product name but not manufacturer) I get a parsing exception due to the blank space.

Are there any standard ways to set up this type of search or any tools that are designed to help with this?

Thanks for any assistance you can provide!


Top
 Profile  
 
 Post subject: Re: Searching with optional parameters
PostPosted: Mon Jul 11, 2011 7:25 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi, since you mention a parsing exception I'm guessing you're using the "QueryParser" provided by Lucene?
There are many more methods to create a Query, I think you should look for BooleanQuery and the programmatic query builder API as described here: http://docs.jboss.org/hibernate/stable/ ... y-querydsl

especially look into the paragraph "combining queries": I think it matches what you're searching for, if not you're welcome to ask more details/clarifications.

Also you can combine queries with filters, make sure you read about filters too.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.