Re: MultiFieldQueryParser with default AND and stopfilter

2011-06-09 Thread Elmer
Thank you Trejkaz! Inspired by your solution I've created the attached extension to the MFQP, a little different than you proposed. In getFieldQuery, if a (stop)word is removed by an analyzer for some field, it will return null, so that term is then ignored (only if using AND as default operator).

Re: MultiFieldQueryParser with default AND and stopfilter

2011-06-08 Thread Trejkaz
On Wed, Jun 8, 2011 at 6:52 PM, Elmer wrote: > the parsed query becomes: > > '+(title:the) +(title:project desc:project)'. > > So, the problem is that docs that have the term 'the' only appearing in > their desc field are excluded from the results. Subclass MFQP and override getFieldQuery. If th

Re: MultiFieldQueryParser with default AND and stopfilter

2011-06-08 Thread Ian Lea
I'm sure you are right and I'm wrong - sorry for the waste of space. However I still think you should build it all up in code. -- Ian. On Wed, Jun 8, 2011 at 4:33 PM, Elmer wrote: >> Using MFQP with AND >> everywhere you'll never get a match if some fields don't contain all >> of the search te

Re: MultiFieldQueryParser with default AND and stopfilter

2011-06-08 Thread Elmer
> Using MFQP with AND > everywhere you'll never get a match if some fields don't contain all > of the search terms" I'm sorry to say, but that's not true I guess, look how the query parser parses the following query: 'information retrieval' --parsed-to--> +(title:inform description:inform authors.

Re: MultiFieldQueryParser with default AND and stopfilter

2011-06-08 Thread Ian Lea
Then surely the stop word issue is a red herring. Using MFQP with AND everywhere you'll never get a match if some fields don't contain all of the search terms. Even if Erick's exact answer won't apply, I suspect that building up a composite boolean query is the way to go. -- Ian. On Wed, Jun 8

Re: MultiFieldQueryParser with default AND and stopfilter

2011-06-08 Thread Elmer
Sorry, I made a mistake here: > Unfortunately, the solution that Erick gave won't do the trick > > > bq.add(qp.parse("title:(the AND project)", SHOULD)) > > > bq.add(qp.parse("desc:(the AND project)", SHOULD)) > This still won't match documents where both 'the' and 'project' appear > in DIFFERENT

Re: MultiFieldQueryParser with default AND and stopfilter

2011-06-08 Thread Elmer
Thank you, I already use the PerFieldAnalyzerWrapper (by Hibernate Search) ;) And that's where the problem comes in: different fields using different analyzers (some with, some without a stopfilter). For each term (tokenized by MFQP itself?), it applies the given analyzer on each field. If the ana

Re: MultiFieldQueryParser with default AND and stopfilter

2011-06-08 Thread Erick Erickson
You're right, that's a better place to start Erick On Wed, Jun 8, 2011 at 9:42 AM, Ian Lea wrote: > Except that I think he has loads of other fields and wants to keep it simple. > > But how about passing a PerFieldAnalyzerWrapper instance as the > analyzer to MFQP?  Worth a try. > > > -- > I

Re: MultiFieldQueryParser with default AND and stopfilter

2011-06-08 Thread Ian Lea
Except that I think he has loads of other fields and wants to keep it simple. But how about passing a PerFieldAnalyzerWrapper instance as the analyzer to MFQP? Worth a try. -- Ian. On Wed, Jun 8, 2011 at 2:38 PM, Erick Erickson wrote: > Could you just construct a BooleanQuery with the > term

Re: MultiFieldQueryParser with default AND and stopfilter

2011-06-08 Thread Erick Erickson
Could you just construct a BooleanQuery with the terms against different fields instead of using MFQP? e.g. bq.add(qp.parse("title:(the AND project)", SHOULD)) bq.add(qp.parse("desc:(the AND project)", SHOULD)) etc...? If your QueryParser was created with a PerFieldAnalyzerWrapper I think you mig

Re: MultiFieldQueryParser with default AND and stopfilter

2011-06-08 Thread Ian Lea
I guess the base problem is that MFQP only accepts one analyzer. Presumably you are using different analyzers for your title and desc fields, and it might do what you wanted if you could pass in a list of analyzers along with a list of fields. Sounds like something that might not be too hard to co

MultiFieldQueryParser with default AND and stopfilter

2011-06-08 Thread Elmer
Hi, I have a use case in which I use the MultiFieldQueryParser (MFQP) on some fields that use and some fields that don't use a stopfilter. The default operator of the MFQP is set to AND. For example, if the search query is 'the project' (with 'the' included in the stoplist) and the search fields a