You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Andy <an...@hotmail.com> on 2010/04/16 00:34:46 UTC

How to search multiple fields using multiple search terms

Hi, I am trying to use the MultiFieldQueryParser to search "title" and "desc" fields.  However the Lucene API appears to only let me provide a single search term.  Is it possible to use multiple search terms (one for each field)?

 

For example, the SQL equivalent would be:


select *
from lucene
where title = 'abc'
and desc = '123'


Thanks!
 		 	   		  
_________________________________________________________________
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1

Re: Doc Caching

Posted by Erick Erickson <er...@gmail.com>.
<<<Is it worth setting up your own caching...>>>

You've hit one of my personal hot buttons <G>.  Never, never, never
until
1> you're reasonably sure you actually *have* a performance issue.
2> your performance issues can't be fixed more cheaply. Memory is
  waaaaaaaay cheap compared to all the time you'll spend programming
  your caching solution then fixing the bugs in it.

Best
Erick

On Tue, Apr 20, 2010 at 1:16 AM, Chris B <ch...@inbox.com> wrote:

> Mike cheers for the reply.
>
> Is it worth setting up your own caching or letting the OS do it? I've setup
> a caching system, but if the OS is doing it it seems pointless.
>
> Chris
>
> ----- Original Message ----- From: "Michael McCandless" <
> lucene@mikemccandless.com>
> To: <ja...@lucene.apache.org>
> Sent: Tuesday, April 20, 2010 2:17 AM
> Subject: Re: Doc Caching
>
>
>
> No, Lucene doesn't.  But the OS usually does (in is IO cache),
> assuming there is spare RAM.
>
> The "only" things that are explicitly held in memory by Lucene are the
> norms ("boost bytes"), terms dict index, deletions bit vector and
> field cache (used eg when you sort by a field), I think.
>
> Mike
>
> On Fri, Apr 16, 2010 at 2:16 AM, Chris B <ch...@inbox.com> wrote:
>
>> Hi
>>
>> Does Lucene cache the documents it retrieves? If so in which object?
>>
>> Chris
>>
>> ____________________________________________________________
>> GET FREE 5GB EMAIL - Check out spam free email with many cool features!
>> Visit http://www.inbox.com/email to find out more!
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Doc Caching

Posted by Ian Lea <ia...@gmail.com>.
Generally best to let the OS do it.  Having plenty of spare RAM is good.


--
Ian.


On Tue, Apr 20, 2010 at 6:16 AM, Chris B <ch...@inbox.com> wrote:
> Mike cheers for the reply.
>
> Is it worth setting up your own caching or letting the OS do it? I've setup
> a caching system, but if the OS is doing it it seems pointless.
>
> Chris
>
> ----- Original Message ----- From: "Michael McCandless"
> <lu...@mikemccandless.com>
> To: <ja...@lucene.apache.org>
> Sent: Tuesday, April 20, 2010 2:17 AM
> Subject: Re: Doc Caching
>
>
> No, Lucene doesn't.  But the OS usually does (in is IO cache),
> assuming there is spare RAM.
>
> The "only" things that are explicitly held in memory by Lucene are the
> norms ("boost bytes"), terms dict index, deletions bit vector and
> field cache (used eg when you sort by a field), I think.
>
> Mike
>
> On Fri, Apr 16, 2010 at 2:16 AM, Chris B <ch...@inbox.com> wrote:
>>
>> Hi
>>
>> Does Lucene cache the documents it retrieves? If so in which object?
>>
>> Chris
>>
>> ____________________________________________________________
>> GET FREE 5GB EMAIL - Check out spam free email with many cool features!
>> Visit http://www.inbox.com/email to find out more!
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Doc Caching

Posted by Chris B <ch...@inbox.com>.
Mike cheers for the reply.

Is it worth setting up your own caching or letting the OS do it? I've setup 
a caching system, but if the OS is doing it it seems pointless.

Chris

----- Original Message ----- 
From: "Michael McCandless" <lu...@mikemccandless.com>
To: <ja...@lucene.apache.org>
Sent: Tuesday, April 20, 2010 2:17 AM
Subject: Re: Doc Caching


No, Lucene doesn't.  But the OS usually does (in is IO cache),
assuming there is spare RAM.

The "only" things that are explicitly held in memory by Lucene are the
norms ("boost bytes"), terms dict index, deletions bit vector and
field cache (used eg when you sort by a field), I think.

Mike

On Fri, Apr 16, 2010 at 2:16 AM, Chris B <ch...@inbox.com> wrote:
> Hi
>
> Does Lucene cache the documents it retrieves? If so in which object?
>
> Chris
>
> ____________________________________________________________
> GET FREE 5GB EMAIL - Check out spam free email with many cool features!
> Visit http://www.inbox.com/email to find out more!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Doc Caching

Posted by Michael McCandless <lu...@mikemccandless.com>.
No, Lucene doesn't.  But the OS usually does (in is IO cache),
assuming there is spare RAM.

The "only" things that are explicitly held in memory by Lucene are the
norms ("boost bytes"), terms dict index, deletions bit vector and
field cache (used eg when you sort by a field), I think.

Mike

On Fri, Apr 16, 2010 at 2:16 AM, Chris B <ch...@inbox.com> wrote:
> Hi
>
> Does Lucene cache the documents it retrieves? If so in which object?
>
> Chris
>
> ____________________________________________________________
> GET FREE 5GB EMAIL - Check out spam free email with many cool features!
> Visit http://www.inbox.com/email to find out more!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Doc Caching

Posted by Chris B <ch...@inbox.com>.
Hi

Does Lucene cache the documents it retrieves? If so in which object?

Chris

____________________________________________________________
GET FREE 5GB EMAIL - Check out spam free email with many cool features!
Visit http://www.inbox.com/email to find out more!

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


RE: How to search multiple fields using multiple search terms

Posted by Andy <an...@hotmail.com>.
I am just getting started with Lucene so I didnt know you could just use a regular query parser.  That seems to work.

Thanks


 
> Date: Thu, 15 Apr 2010 19:32:50 -0400
> Subject: Re: How to search multiple fields using multiple search terms
> From: erickerickson@gmail.com
> To: java-user@lucene.apache.org
> 
> Why are you locked into using MultiFieldQueryParser? The simpler approach is
> just send something like +title:abc +desc:123 through the regular query
> parser....
> 
> HTH
> Erick
> 
> On Thu, Apr 15, 2010 at 6:34 PM, Andy <an...@hotmail.com> wrote:
> 
> >
> > Hi, I am trying to use the MultiFieldQueryParser to search "title" and
> > "desc" fields. However the Lucene API appears to only let me provide a
> > single search term. Is it possible to use multiple search terms (one for
> > each field)?
> >
> >
> >
> > For example, the SQL equivalent would be:
> >
> >
> > select *
> > from lucene
> > where title = 'abc'
> > and desc = '123'
> >
> >
> > Thanks!
> >
> > _________________________________________________________________
> > Hotmail has tools for the New Busy. Search, chat and e-mail from your
> > inbox.
> >
> > http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1
> >
 		 	   		  
_________________________________________________________________
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5

Re: How to search multiple fields using multiple search terms

Posted by Erick Erickson <er...@gmail.com>.
Why are you locked into using MultiFieldQueryParser? The simpler approach is
just send something like +title:abc +desc:123 through the regular query
parser....

HTH
Erick

On Thu, Apr 15, 2010 at 6:34 PM, Andy <an...@hotmail.com> wrote:

>
> Hi, I am trying to use the MultiFieldQueryParser to search "title" and
> "desc" fields.  However the Lucene API appears to only let me provide a
> single search term.  Is it possible to use multiple search terms (one for
> each field)?
>
>
>
> For example, the SQL equivalent would be:
>
>
> select *
> from lucene
> where title = 'abc'
> and desc = '123'
>
>
> Thanks!
>
> _________________________________________________________________
> Hotmail has tools for the New Busy. Search, chat and e-mail from your
> inbox.
>
> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1
>