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 Sergiu Gordea <gs...@ifit.uni-klu.ac.at> on 2004/07/06 10:09:00 UTC
MultifieldQueryParser.parse()
Hi all,
I have a question,
I have an index with more fileds and I have to create conjunctive
queries by default.
So what I'm trying to say is that we develop a project and we provide
search functionality
basing on lucene indexer.
From what I can see, Multifield query parser creates disjunctive queries:
if I search for "best test" in fields {title, description} the
MultiFieldQueryParser.parse(string, fields, analizer)
will create a query that will mean "fields contain 'best' OR fileds
contain 'test'" [1]
by I want to create "fields contain 'best' AND fileds contain 'test'"[2]
I know, I can place a + before each of this terms, but we also want to
let the users to create
custom queries using logical operators and + -, grouping and exact phrases.
So in this situation we have to parse the query string twice wit the
only change that we will ad AND operator to
link the TERMS in the places were no operator is found.
This seems to me to be just overhead, and I think that tha best way
would be to overload parse function to
MultiFieldQueryParser.parse(String queryString, String[] fields,
Analizer analizer, String/int defaultoperator)[3]
were default operator can be "AND" or "OR"
so that I can choose if I want to create query [1] or query [2].
Do we have an alternative solution, reasonably simple for this problem?
What do you think about my suggestion of implementing the [3] method .
Thanks for understanding,
Sergiu
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: MultifieldQueryParser.parse()
Posted by Daniel Naber <da...@t-online.de>.
On Tuesday 06 July 2004 11:19, Sergiu Gordea wrote:
> >(+title:a +title:b) (+body:a +body:b)
> >
> ... unfortunately you are right, but it is a pitty that it not working
> as we want to,
> it seemed to be so useful. It seems that this is the backside of the
> "reverse indexing" medal...
>
> Has anyone some Ideeas about how can we avoid this situation?
You'll have to do a real query rewriting, as Nutch does. So "+a +b" will
become +(title:a body:a) + (title:b body:b)
Unfortunately you cannot just copy+paste code from Nutch as they added a layer
on top of the query stuff (or something like that).
Regards
Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: MultifieldQueryParser.parse()
Posted by Sergiu Gordea <gs...@ifit.uni-klu.ac.at>.
Daniel Naber wrote:
>On Tuesday 06 July 2004 10:09, Sergiu Gordea wrote:
>
>
>
>>Do we have an alternative solution, reasonably simple for this problem?
>>
>>
>
>No, but are you sure that MultifieldQueryParser does the right thing at all?
>If someone searches for +a +b the parser will (currently) build something
>like this (assuming the fields you want to search arw title and body):
>
>(+title:a +title:b) (+body:a +body:b)
>
>
>
... unfortunately you are right, but it is a pitty that it not working
as we want to,
it seemed to be so useful. It seems that this is the backside of the
"reverse indexing" medal...
Has anyone some Ideeas about how can we avoid this situation?
Except ... indexing everithing in one column?
Or ... do we have some other classes as an alternative to
MultifieldQueryParser?
Thanks,
Sergiu
>This is usually not what I'd expect: the user wants both terms to occur, no
>matter in which field ('a' might be in title, 'b' might be in body). So I
>think MultifieldQueryParser is just broken for many use cases.
>
>Regards
> Daniel
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: MultifieldQueryParser.parse()
Posted by Kelvin Tan <li...@relevanz.com>.
Hi Sergiu,
First of all, if your application is web-based, its not necessary to
programmatically construct the query based on user-input (via
MultiFieldQueryParser). you can use luceneQueryConstructor.js in Lucene sandbox.
You can find the documentation here:
http://cvs.apache.org/viewcvs.cgi/*checkout*/jakarta-lucene-sandbox/contribution
s/javascript/queryConstructor/luceneQueryConstructor.html
Secondly, if still necessary to programmatically construct the query, perhaps
you can consider creating an int[] of MultiFieldQueryParser.REQUIRED_FIELD and
using
public static Query parse(String query, String[] fields, int[] flags,
Analyzer analyzer)
instead?
Kelvin
On Tue, 06 Jul 2004 10:09:00 +0200, Sergiu Gordea said:
>
> Hi all,
> I have a question,
> I have an index with more fileds and I have to create conjunctive
> queries by default.
> So what I'm trying to say is that we develop a project and we provide
> search functionality
> basing on lucene indexer.
> From what I can see, Multifield query parser creates disjunctive queries:
> if I search for "best test" in fields {title, description} the
> MultiFieldQueryParser.parse(string, fields, analizer)
> will create a query that will mean "fields contain 'best' OR fileds
> contain 'test'" [1]
> by I want to create "fields contain 'best' AND fileds contain 'test'"[2]
> I know, I can place a + before each of this terms, but we also want to
> let the users to create
> custom queries using logical operators and + -, grouping and exact phrases.
> So in this situation we have to parse the query string twice wit the
> only change that we will ad AND operator to
> link the TERMS in the places were no operator is found.
> This seems to me to be just overhead, and I think that tha best way
> would be to overload parse function to
> MultiFieldQueryParser.parse(String queryString, String[] fields,
> Analizer analizer, String/int defaultoperator)[3]
> were default operator can be "AND" or "OR"
> so that I can choose if I want to create query [1] or query [2].
> Do we have an alternative solution, reasonably simple for this problem?
> What do you think about my suggestion of implementing the [3] method .
>
> Thanks for understanding,
> Sergiu
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
dow
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org