-->
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.  [ 4 posts ] 
Author Message
 Post subject: Adding a filed to the search query
PostPosted: Sat Dec 26, 2009 8:01 pm 
Newbie

Joined: Sat Dec 26, 2009 7:56 pm
Posts: 2
Hi there,

I have a list of fields which I'm adding to the query using MultiFieldQueryParser. The query constructed is what I want. I have a situation where I need to add another field to the query which will always have the same value to be searched.

For Example my current code is
private String[] opportunityFields = { "oppSubject", "oppSolNbr",
"oppDesc", "oppSetaside", "oppLocation", };

QueryParser parser = new MultiFieldQueryParser(opportunityFields,
new StandardAnalyzer());

Query luceneQuery = parser.parse(this.queryString);

Now I want to add a field call isactive and I want to search for a value Y

How can I do that ?

- Harjit


Top
 Profile  
 
 Post subject: Re: Adding a filed to the search query
PostPosted: Mon Dec 28, 2009 11:59 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
I'd suggest you to use a FullTextFilter. You can apply a filter on top of a query and it can be cached, so you can reuse the filter for many queries: that makes it a good choice in case the value is always the same. Also it's good to apply "programmatic" constraints to dynamic generated queries as you do.

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


Top
 Profile  
 
 Post subject: Re: Adding a filed to the search query
PostPosted: Mon Dec 28, 2009 2:29 pm 
Newbie

Joined: Sat Dec 26, 2009 7:56 pm
Posts: 2
Thanks a bunch. I will try that. Is there an example on it ?

Thanks

- Harjit


Top
 Profile  
 
 Post subject: Re: Adding a filed to the search query
PostPosted: Mon Dec 28, 2009 3:06 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
reference documentation has some examples: http://docs.jboss.org/hibernate/stable/ ... e/#d0e2970
There are more in the unit tests (look into the sources), and Hibernate Search in Action (The book) as a whole chapter on it with more examples and implementations.

_________________
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.  [ 4 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.