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 Melanie Langlois <Me...@tradingscreen.com> on 2007/03/26 10:51:37 UTC

search on multiple fields

Hi,

 

I'm wondering if lucene would understand such a query:

 

content*:mysearch

It's just because I index several translations of my document contents in addition with common fields, and this separation is really usefull when an user specify the language in which he wants to search, but I want to be able to search among all languages if no option is specified. I could programmatically transform my content* into several sub queries content-en:mysearch content-fr:mysearch ... but I'm concerned about the number of conditions it will generate. So that would be cool if lucene automatically look into all concerned fields.

 

Thanks,

 

Mélanie  

 

 


Re: search on multiple fields

Posted by Daniel Noll <da...@nuix.com>.
Melanie Langlois wrote:
> Hi,
> 
> I'm wondering if lucene would understand such a query:
> 
> content*:mysearch
> 
> It's just because I index several translations of my document
> contents in addition with common fields, and this separation is
> really usefull when an user specify the language in which he wants to
> search, but I want to be able to search among all languages if no
> option is specified. I could programmatically transform my content*
> into several sub queries content-en:mysearch content-fr:mysearch ...
> but I'm concerned about the number of conditions it will generate. So
> that would be cool if lucene automatically look into all concerned
> fields.

You could probably subclass QueryParser to do something like this.

The naive way would be to have the subclass build a BooleanQuery as you 
mentioned already.  A less naive way would be to create a 
MultiFieldTermQuery which extends from MultiTermQuery, and does the 
enumeration over the fields which match the prefix.  You'd probably need 
to do the same for phrases though which would be more difficult. :-)

Daniel



-- 
Daniel Noll

Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia    Ph: +61 2 9280 0699
Web: http://nuix.com/                               Fax: +61 2 9212 6902

This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.

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


Re: search on multiple fields

Posted by Grant Ingersoll <gs...@apache.org>.
Have a look at the MultifieldQueryParser.  It isn't exactly what you  
are describing, but should be able to handle it.  If you are building  
your queries programmatically, you can ask the IndexReader for the  
field names using  getFieldNames method.

On Mar 26, 2007, at 4:51 AM, Melanie Langlois wrote:

> Hi,
>
>
>
> I'm wondering if lucene would understand such a query:
>
>
>
> content*:mysearch
>
> It's just because I index several translations of my document  
> contents in addition with common fields, and this separation is  
> really usefull when an user specify the language in which he wants  
> to search, but I want to be able to search among all languages if  
> no option is specified. I could programmatically transform my  
> content* into several sub queries content-en:mysearch content- 
> fr:mysearch ... but I'm concerned about the number of conditions it  
> will generate. So that would be cool if lucene automatically look  
> into all concerned fields.
>
>
>
> Thanks,
>
>
>
> Mélanie
>
>
>
>
>

--------------------------
Grant Ingersoll
Center for Natural Language Processing
http://www.cnlp.org

Read the Lucene Java FAQ at http://wiki.apache.org/jakarta-lucene/ 
LuceneFAQ



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


Re: search on multiple fields

Posted by Erick Erickson <er...@gmail.com>.
The fastest way to figure this out for yourself would be to fire up luke
and try it.

That said, I'm quite sure it won't work.

Erick

On 3/26/07, Melanie Langlois <Me...@tradingscreen.com> wrote:
>
> Hi,
>
>
>
> I'm wondering if lucene would understand such a query:
>
>
>
> content*:mysearch
>
> It's just because I index several translations of my document contents in
> addition with common fields, and this separation is really usefull when an
> user specify the language in which he wants to search, but I want to be able
> to search among all languages if no option is specified. I could
> programmatically transform my content* into several sub queries
> content-en:mysearch content-fr:mysearch ... but I'm concerned about the
> number of conditions it will generate. So that would be cool if lucene
> automatically look into all concerned fields.
>
>
>
> Thanks,
>
>
>
> Mélanie
>
>
>
>
>
>