lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Incze Lajos <in...@mail.matav.hu>
Subject Re: "starts with" query functionality
Date Sat, 03 Apr 2004 01:08:32 GMT
On Fri, Apr 02, 2004 at 10:20:54AM -0600, Chad Small wrote:
> We have a requirement to return documents with a "title" field that starts with a certain
letter.  Is there a way to do something like this?  We're using the StandardAnalyzer
>  
> Example title fields:
>  
> This is the title of a document.
> And this is a title of a different document.
>  
> This query doesn't fulfill the requirement:
> +(t*)  - just want to return the 1st document that starts with "This", and not the 2nd
article that has "this" as the 2nd word.
>  
> Or is it just a matter of creating a field in the index called "title_starts_with" that
would look like this for the example:
>  
> T
> A
>  
> Now, the query +(t) would only get a hit on the 1st document.
> Or is there a better way?
>  
> thanks,
> chad.

Basically that's a good solution, but you'd better to
make an instance of your titles as an indexed and untokenized
field, too,  to prevent the tokenizer split your titles
into tokens. This way, you have a start as long as you want.

incze

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