lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Braun <mbr...@uni-hd.de>
Subject Re: Best approach for exact Prefix Field Query
Date Thu, 16 Nov 2006 15:13:43 GMT
hi Erik,

> "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?
Yes, it works (see below)!
... but with my Java-App I have the Problem that I need to combine this
SpanFirstQuery with a Query from the QueryParser,
i.e. from the Webform I get the SpanFirstQuery (which I am just
.split'ing as inJRuby Sample) and I get another inputfield with a query
I normally parse with the QueryParser.

Is there a way to merge these two query-classes?

tia,
martin


   SpanFirstQuery = org.apache.lucene.search.spans.SpanFirstQuery
   SpanTermQuery  = org.apache.lucene.search.spans.SpanTermQuery
   SpanQuery  = org.apache.lucene.search.spans.SpanQuery
   SpanNearQuery  = org.apache.lucene.search.spans.SpanNearQuery

   Term = org.apache.lucene.index.Term

   qs = search.split(/\s/)

   spanq_ar =SpanQuery[].new(qs.length)

   for i in 0...qs.length
      spanq_ar[i] = SpanTermQuery.new( Term.new("TI", qs[i] ) )
   end

   sp = SpanFirstQuery.new(SpanNearQuery.new(spanq_ar,1,true),
spanq_ar.length)
   hits = searcher.search(sp)
   for i in 0...hits.length
      puts hits.doc(i).getField("kurz")
   end



-- 
Universitaetsbibliothek Heidelberg   Tel: +49 6221 54-2580
Ploeck 107-109, D-69117 Heidelberg   Fax: +49 6221 54-2623

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