lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Scheffler" <thomas.scheff...@uni-jena.de>
Subject Re: merged search of document
Date Mon, 12 Jan 2004 16:10:01 GMT

Thomas Scheffler sagte:
>
> Erik Hatcher sagte:
>> On Jan 12, 2004, at 8:21 AM, Thomas Scheffler wrote:
>>> OK, I've looked inside QueryParser and it's seems to be the right
>>> place to
>>> do that. But it's rather complicated to transform a query to another,
>>> since QueryParserTokenManager as an extreme example is not quite
>>> understandable and needs a huge time for all that stuff to work in.
>>
>> Keep in mind that QueryParser is reasonably overridable.  Simply
>> subclass it and override one of the get*Query methods.  This may be the
>> simplest way for you to inject additional clauses into a query.
>
> You're right if the source query consist of a non atomic query. If it's a
> combined one it does allready function quite well. Because of the last
> check in Query(String) of QueryParser it returns firstQuery then and
> getBooleanQuery is never called. As I'm not able to overwrite
> Query(String) I'm not quite sure how to handle searches like: foo.
>

Of cause you can overwrite parse(String), so I do.

public Query parse(String query) throws ParseException{
	Query queryTemp=super.parse(query);
	if (queryTemp.toString(field).equals(query)){
		Vector v=new Vector();
		BooleanClause clause=new BooleanClause(queryTemp,true,false);
		v.add(clause);
		return getBooleanQuery(v);
	}
	return queryTemp;
}

Now all relevant cases seem to function. Thanks for the help. You were
pushing a great step forward in my working progress.



-- 


---------------------------------------------------------------------
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