lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: Starts With x and Ends With x Queries
Date Sat, 05 Feb 2005 01:07:35 GMT
It matches both because you're tokenizing the name field.  In both 
documents, the name field has a "testing" term in it (it gets 
lowercased also).  A PrefixQuery matches terms that start with the 
prefix.  Use an untokenized field type (Field.Keyword) if you want to 
keep the entire original string as-is for searching purposes - however 
you'd have issues with case-sensitivity in your example.

Also keep in mind that QueryParser only allows a trailing asterisk, 
creating a PrefixQuery.  However, if you use a WildcardQuery directly, 
you can use an asterisk as the starting character (at the risk of 
performance).

	Erik


On Feb 4, 2005, at 7:50 PM, Luke Shannon wrote:

> Hello;
>
> I have these two documents:
>
> Text<sort:9>
> Keyword<modified:0e1as4og8>
> Text<progress_ref:1099927045180>
> Text<name:FutureBrand Testing>
> Text<desc:Demo>
> Text<anouncement:We are testing our project>
> Text<category:Category 1>
> Text<olfaithfull:stillhere>
> Text<poster:hello>
> Text<urgent:yes>
> Text<provider:Mo>
>
>
> Text<sort:1>
> Text<Author:cbalom>
> Text<Creator:PScript5.dll Version 5.2.2>
> Keyword<modified:0e1bgsfk0>
> Keyword<modified:0e1bgsfk0>
> Text<Producer:Acrobat Distiller 5.0.5 (Windows)>
> Text<progress_ref:1099957931806>
> Text<name:testing stuff>
> Text<desc:testing>
> Text<category:Category 1>
> Text<olfaithfull:stillhere>
> Text<poster:hello>
> Text<Title:Microsoft Word - FINAL-FutureBrand Creates, Launches 'Air 
> Canada'
> Brand Ide.>
> Text<provider:Ray>
> Text<kcfileupload:aircanada3.pdf>
>
> I would like to be able to match a name fields that starts with testing
> (specifically) and those that end with it.
>
> I thought the below code would parse to a Prefix Query that would 
> satisfy my
> starting requirment (maybe I don't understand what this query is for). 
> But
> this matches both.
>
> Query query = QueryParser.parse("testing*", "name", new 
> StandardAnalyzer());
>
> Has anyone done this before? Any tips?
>
> Thanks,
>
> Luke
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org


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