-->
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 with MultifieldParser and specifying conditions
PostPosted: Mon Nov 22, 2010 8:07 pm 
Newbie

Joined: Mon Nov 22, 2010 7:55 pm
Posts: 6
Hi,

How do I specify a search like this in Hibernate Search?

select * from table where keyword is "java" and location in "new york " and category in "Science" ?

I was using <ultifieldparser but it is not working. It is returning all the field.

String[] queries = new String[]{keyword,location, category};
String[] fields = new String[]{"title","category","city", "state","zipcode"};
String preProcessedSearchTerms = new QueryTermsProcessor()
.processQueryTerms(criteria, new String[] {
"title","category","city", "state","zipcode" },
QueryOperator.OR);
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields,new StandardAnalyzer());
// System.out.println(query.toString());
EntityManager em = this.jobDao.getEm();

org.apache.lucene.search.Query query = parser.parse(preProcessedSearchTerms);

FullTextEntityManager fullTextEntityManager = Search
.getFullTextEntityManager(em);
FullTextQuery fullTextQuery = fullTextEntityManager
.createFullTextQuery(query, Job.class);

Any hints?

Thanks,


Top
 Profile  
 
 Post subject: Re: Query with MultifieldParser and specifying conditions
PostPosted: Tue Nov 23, 2010 9:44 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
I guess you're looking for something like this

Code:
keyword:java AND location:"new york" AND category:Science


That would match all documents that contain keyword java, location "new york" and category science.

That is the simplest approach. You refer to the query syntax in lucene to get more information http://lucene.apache.org/java/2_4_0/que ... yntax.html


Top
 Profile  
 
 Post subject: Re: Query with MultifieldParser and specifying conditions
PostPosted: Tue Nov 23, 2010 4:05 pm 
Newbie

Joined: Mon Nov 22, 2010 7:55 pm
Posts: 6
Hi,

what i want is to get all java job located in New York and in the science category.

How can i express that.

The Query will in sql like that:

select * from job where keyword ='java' and city in('New York') and category in ('science');

Thanks,


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.