> Since you can't (and it doesn't make sense to) use
> wildcards in phrase
> queries, how do you construct a query to get results for
> phrases that begin with a certain set of terms?  
> Here are some theoretical examples...
> 
> 
> Example 1 - I have an index where each document contains
> the contents of
> short stories.  I want to return each document that
> begins with the
> words "Once upon a time".  I know this in not valid
> Lucene syntax, but
> what I would like to do is query for "Once upon a time"*

You are trying to retrieve documents begins with "Once upon a time", right? You 
want your phrase in the beginning of the document. You can retrieve them using 
SpanQuery family programmatically.

I am not sure about the value of (int end) in SpanFirstQuery constructor but it 
will be something like that:

s1 = new SpanTermQuery(new Term("story","once"));
s2 = new SpanTermQuery(new Term("story","upon"));
s3 = new SpanTermQuery(new Term("story","time"));

s4 = new SpanNearQuery([s1,s2,s3], 0, true);

s5 = new SpanFirstQuery(s4, 3);

Note that you need to use analyzed text of terms in this approach.

Hope this helps.




---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to