You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by mrw <mi...@gmail.com> on 2011/03/02 20:28:04 UTC

Re: Understanding multi-field queries with q and fq

Anyone understand how to do boolean logic across multiple fields?  

Dismax is nice for searching multiple fields, but doesn't necessarily
support our syntax requirements. eDismax appears to be not available until
Solr 3.1.   

In the meantime, it looks like we need to support applying the user's query
to multiple fields, so if the user enters "led zeppelin merle" we need to be
able to do the logical equivalent of 

&fq=field1:led zeppelin merle OR field2:led zeppelin merle


Any ideas?  :)



mrw wrote:
> 
> After searching this list, Google, and looking through the Pugh book, I am
> a little confused about the right way to structure a query.
> 
> The Packt book uses the example of the MusicBrainz DB full of song
> metadata.  What if they also had the song lyrics in English and German as
> files on disk, and wanted to index them along with the metadata, so that
> each document would basically have song title, artist, publisher, date,
> ..., All_Metadata (copy field of all metadata fields), Text_English, and
> Text_German fields?  
> 
> There can only be one default field, correct?  So if we want to search for
> all songs containing (zeppelin AND (dog OR merle)) do we 
> 
> repeat the entire query text for all three major fields in the 'q' clause
> (assuming we don't want to use the cache):
> 
> q=(+All_Metadata:zeppelin AND (dog OR merle)+Text_English:zeppelin AND
> (dog OR merle)+Text_German:(zeppelin AND (dog OR merle))
> 
> or repeat the entire query text for all three major fields in the 'fq'
> clause (assuming we want to use the cache):
> 
> q=*:*&fq=(+All_Metadata:zeppelin AND (dog OR merle)+Text_English:zeppelin
> AND (dog OR merle)+Text_German:zeppelin AND (dog OR merle))
> 
> ?
> 
> Thanks!
> 


--
View this message in context: http://lucene.472066.n3.nabble.com/Understanding-multi-field-queries-with-q-and-fq-tp2528866p2619700.html
Sent from the Solr - User mailing list archive at Nabble.com.

RE: Understanding multi-field queries with q and fq

Posted by mrw <mi...@gmail.com>.
Yes, we're investigating dismax (with the qf param), but we're not sure it
supports our syntax needs.  The users want to put put AND/OR/NOT in their
queries, and we don't want to write a lot of code converting those queries
into dismax (+/-/mm) format.  So, until 3.1 (edismax) ships, we're also
trying to get boolean queries to work across multiple fields with the
standard query handler.

I've seen quite a few unanswered or partially-answered posts on this list on
getting boolean syntax right.  I can tell it's a thorny issue.


Robert Sandiford wrote:
> 
> Have you looked at the 'qf' parameter?
> 
> Bob Sandiford | Lead Software Engineer | SirsiDynix
> P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
> www.sirsidynix.com 
> _____
> http://www.cosugi.org/ 
> 
> 
> 
> 
>> -----Original Message-----
>> From: mrw [mailto:mikerobertswork@gmail.com]
>> Sent: Wednesday, March 02, 2011 2:28 PM
>> To: solr-user@lucene.apache.org
>> Subject: Re: Understanding multi-field queries with q and fq
>> 
>> Anyone understand how to do boolean logic across multiple fields?
>> 
>> Dismax is nice for searching multiple fields, but doesn't necessarily
>> support our syntax requirements. eDismax appears to be not available
>> until
>> Solr 3.1.
>> 
>> In the meantime, it looks like we need to support applying the user's
>> query
>> to multiple fields, so if the user enters "led zeppelin merle" we need
>> to be
>> able to do the logical equivalent of
>> 
>> &fq=field1:led zeppelin merle OR field2:led zeppelin merle
>> 
>> 
>> Any ideas?  :)
>> 
>> 
>> 
>> mrw wrote:
>> >
>> > After searching this list, Google, and looking through the Pugh book,
>> I am
>> > a little confused about the right way to structure a query.
>> >
>> > The Packt book uses the example of the MusicBrainz DB full of song
>> > metadata.  What if they also had the song lyrics in English and
>> German as
>> > files on disk, and wanted to index them along with the metadata, so
>> that
>> > each document would basically have song title, artist, publisher,
>> date,
>> > ..., All_Metadata (copy field of all metadata fields), Text_English,
>> and
>> > Text_German fields?
>> >
>> > There can only be one default field, correct?  So if we want to
>> search for
>> > all songs containing (zeppelin AND (dog OR merle)) do we
>> >
>> > repeat the entire query text for all three major fields in the 'q'
>> clause
>> > (assuming we don't want to use the cache):
>> >
>> > q=(+All_Metadata:zeppelin AND (dog OR merle)+Text_English:zeppelin
>> AND
>> > (dog OR merle)+Text_German:(zeppelin AND (dog OR merle))
>> >
>> > or repeat the entire query text for all three major fields in the
>> 'fq'
>> > clause (assuming we want to use the cache):
>> >
>> > q=*:*&fq=(+All_Metadata:zeppelin AND (dog OR
>> merle)+Text_English:zeppelin
>> > AND (dog OR merle)+Text_German:zeppelin AND (dog OR merle))
>> >
>> > ?
>> >
>> > Thanks!
>> >
>> 
>> 
>> --
>> View this message in context:
>> http://lucene.472066.n3.nabble.com/Understanding-multi-field-queries-
>> with-q-and-fq-tp2528866p2619700.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
> 


--
View this message in context: http://lucene.472066.n3.nabble.com/Understanding-multi-field-queries-with-q-and-fq-tp2528866p2625068.html
Sent from the Solr - User mailing list archive at Nabble.com.

RE: Understanding multi-field queries with q and fq

Posted by Bob Sandiford <bo...@sirsidynix.com>.
Have you looked at the 'qf' parameter?

Bob Sandiford | Lead Software Engineer | SirsiDynix
P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
www.sirsidynix.com 
_____
http://www.cosugi.org/ 




> -----Original Message-----
> From: mrw [mailto:mikerobertswork@gmail.com]
> Sent: Wednesday, March 02, 2011 2:28 PM
> To: solr-user@lucene.apache.org
> Subject: Re: Understanding multi-field queries with q and fq
> 
> Anyone understand how to do boolean logic across multiple fields?
> 
> Dismax is nice for searching multiple fields, but doesn't necessarily
> support our syntax requirements. eDismax appears to be not available
> until
> Solr 3.1.
> 
> In the meantime, it looks like we need to support applying the user's
> query
> to multiple fields, so if the user enters "led zeppelin merle" we need
> to be
> able to do the logical equivalent of
> 
> &fq=field1:led zeppelin merle OR field2:led zeppelin merle
> 
> 
> Any ideas?  :)
> 
> 
> 
> mrw wrote:
> >
> > After searching this list, Google, and looking through the Pugh book,
> I am
> > a little confused about the right way to structure a query.
> >
> > The Packt book uses the example of the MusicBrainz DB full of song
> > metadata.  What if they also had the song lyrics in English and
> German as
> > files on disk, and wanted to index them along with the metadata, so
> that
> > each document would basically have song title, artist, publisher,
> date,
> > ..., All_Metadata (copy field of all metadata fields), Text_English,
> and
> > Text_German fields?
> >
> > There can only be one default field, correct?  So if we want to
> search for
> > all songs containing (zeppelin AND (dog OR merle)) do we
> >
> > repeat the entire query text for all three major fields in the 'q'
> clause
> > (assuming we don't want to use the cache):
> >
> > q=(+All_Metadata:zeppelin AND (dog OR merle)+Text_English:zeppelin
> AND
> > (dog OR merle)+Text_German:(zeppelin AND (dog OR merle))
> >
> > or repeat the entire query text for all three major fields in the
> 'fq'
> > clause (assuming we want to use the cache):
> >
> > q=*:*&fq=(+All_Metadata:zeppelin AND (dog OR
> merle)+Text_English:zeppelin
> > AND (dog OR merle)+Text_German:zeppelin AND (dog OR merle))
> >
> > ?
> >
> > Thanks!
> >
> 
> 
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Understanding-multi-field-queries-
> with-q-and-fq-tp2528866p2619700.html
> Sent from the Solr - User mailing list archive at Nabble.com.



Re: Understanding multi-field queries with q and fq

Posted by Sujit Pal <su...@comcast.net>.
This could probably be done using a custom QParser plugin?

Define the pattern like this:

String queryTemplate = "title:%Q%^2.0 body:%Q%";

then replace the %Q% with the value of the Q param, send it through
QueryParser.parse() and return the query.

-sujit

On Wed, 2011-03-02 at 11:28 -0800, mrw wrote:
> Anyone understand how to do boolean logic across multiple fields?  
> 
> Dismax is nice for searching multiple fields, but doesn't necessarily
> support our syntax requirements. eDismax appears to be not available until
> Solr 3.1.   
> 
> In the meantime, it looks like we need to support applying the user's query
> to multiple fields, so if the user enters "led zeppelin merle" we need to be
> able to do the logical equivalent of 
> 
> &fq=field1:led zeppelin merle OR field2:led zeppelin merle
> 
> 
> Any ideas?  :)
> 
> 
> 
> mrw wrote:
> > 
> > After searching this list, Google, and looking through the Pugh book, I am
> > a little confused about the right way to structure a query.
> > 
> > The Packt book uses the example of the MusicBrainz DB full of song
> > metadata.  What if they also had the song lyrics in English and German as
> > files on disk, and wanted to index them along with the metadata, so that
> > each document would basically have song title, artist, publisher, date,
> > ..., All_Metadata (copy field of all metadata fields), Text_English, and
> > Text_German fields?  
> > 
> > There can only be one default field, correct?  So if we want to search for
> > all songs containing (zeppelin AND (dog OR merle)) do we 
> > 
> > repeat the entire query text for all three major fields in the 'q' clause
> > (assuming we don't want to use the cache):
> > 
> > q=(+All_Metadata:zeppelin AND (dog OR merle)+Text_English:zeppelin AND
> > (dog OR merle)+Text_German:(zeppelin AND (dog OR merle))
> > 
> > or repeat the entire query text for all three major fields in the 'fq'
> > clause (assuming we want to use the cache):
> > 
> > q=*:*&fq=(+All_Metadata:zeppelin AND (dog OR merle)+Text_English:zeppelin
> > AND (dog OR merle)+Text_German:zeppelin AND (dog OR merle))
> > 
> > ?
> > 
> > Thanks!
> > 
> 
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Understanding-multi-field-queries-with-q-and-fq-tp2528866p2619700.html
> Sent from the Solr - User mailing list archive at Nabble.com.