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: Best approach for exact Prefix Field Query
Date Tue, 14 Nov 2006 16:46:07 GMT

On Nov 14, 2006, at 11:18 AM, Martin Braun wrote:
> Hi Erik,
>
>> SpanFirstQuery is what you're after.
>
> thanks for this hint (@Erick: thanks for the good explanation of my  
> prob),
>
> I read the chapter for the spanfirstquery in LIA, but what I don't
> understand is, how do i have to do a "Phrase" SpanFirstQuery?
> I found a message with example code (
> http://www.nabble.com/Speedup-indexing-process- 
> tf1140025.html#a3034612 ):
>
> here's my jruby snippet:
>
>    SpanFirstQuery = org.apache.lucene.search.spans.SpanFirstQuery
>    SpanTermQuery = org.apache.lucene.search.spans.SpanTermQuery
>    Term = org.apache.lucene.index.Term
>
>    sp = SpanFirstQuery.new(SpanTermQuery.new(Term.new("TI",search)),2)
>    hits = searcher.search(sp)
>    for i in 0...hits.length
>       puts hits.doc(i).getField("kurz")
>    end
>
> I get no results for "action and" (there are some docs with beginning
> with "action and" in the title) but i get (correct) results for  
> "action",
> What am I doing wrong here?

"action and" is likely not a single Term, so you'll want to create a  
SpanNearQuery of those individual terms (that match the way they were  
when analyzed and indexed, mind you) and use a SpanNearQuery inside a  
SpanFirstQuery.   Make sense?

JRuby!  Yeehaw!

	Erik



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


Mime
View raw message