lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kelvin Tan <lists-kel...@relevanz.com>
Subject Re: MultifieldQueryParser.parse()
Date Tue, 06 Jul 2004 09:26:17 GMT
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


Mime
View raw message