I think this is possible, at the Lucene level.

You want a mix of PrefixQuery and SpanFirstQuery (hmm we don't have a
SpanLastQuery...).

I believe you can do this by creating a PrefixQuery, and then
customizing the rewrite method to create a BQ (SHOULD clauses) of
SpanFirstQuery, instead of TermQuery that's used by default.
Alternatively, you could enum all matching terms and then build the BQ
yourself... but you'll have to be careful when too many terms match
the prefix.

Mike

On Tue, Oct 5, 2010 at 2:39 AM, Maddy.Jsh <madhusudanrjo...@gmail.com> wrote:
>
> Hi,
>
> I have 2 documents with following values.
> Doc1
> Subject: Weekly transport
>
> Doc2
> Subject: Week report on transportation
>
> I need to search documents in 4 formats
>
> 1. Begins with “week”
>     It should return documents which has "week" as first word, i.e. doc1
>
> 2. Begins with “week*”
>     It should return documents which has "week" or its derivatives(weekly,
> weeks) as first word, i.e. doc1 and doc2
>
> 3. Ends with “transport”
>     It should return documents which end with word "transport", i.e. doc1
>
> 4. Ends with “transport*”
>     It should return documents which end with word "transport" or its
> derivatives(transportation, transporter, etc), i.e. doc1 and doc2
>
>
> Please let me know if there are any solutions.
>
> Thanks.
>
>
>
>
>
>
> --
> View this message in context: 
> http://lucene.472066.n3.nabble.com/Begins-with-and-ends-with-word-tp1634376p1634376.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Reply via email to