/// <summary> Convenience routine to make it easy to return the most interesting words in a document. /// More advanced users will call {@link #RetrieveTerms(java.io.Reader) retrieveTerms()} directly. /// </summary> /// <param name="r">the source document /// </param> /// <returns> the most interesting words in the document /// /// </returns> /// <seealso cref="#RetrieveTerms(java.io.Reader)"> /// </seealso> /// <seealso cref="#setMaxQueryTerms"> /// </seealso> public String[] RetrieveInterestingTerms(StreamReader r) { ArrayList al = new ArrayList(maxQueryTerms); Lucene.Net.Util.PriorityQueue pq = RetrieveTerms(r); Object cur; int lim = maxQueryTerms; // have to be careful, retrieveTerms returns all words but that's probably not useful to our caller... // we just want to return the top words while (((cur = pq.Pop()) != null) && lim-- > 0) { PQRecord ar = (PQRecord)cur; al.Add(ar.word); // the 1st entry is the interesting word } String[] res = new String[al.Count]; // return (System.String[]) SupportClass.ICollectionSupport.ToArray(al, res); return((String[])al.ToArray(typeof(String))); }
/// <summary> Create the More like query from a PriorityQueue</summary> private Query CreateQuery(Lucene.Net.Util.PriorityQueue q) { Lucene.Net.Search.BooleanQuery query = new Lucene.Net.Search.BooleanQuery(); Object cur; int qterms = 0; float bestScore = 0; while (((cur = q.Pop()) != null)) { PQRecord ar = (PQRecord)cur; Lucene.Net.Search.TermQuery tq = new Lucene.Net.Search.TermQuery(new Term(ar.topField, ar.word)); if (boost) { if (qterms == 0) { bestScore = ar.score; } float myScore = ar.score; tq.SetBoost(myScore / bestScore); } try { query.Add(tq, Lucene.Net.Search.BooleanClause.Occur.SHOULD); } catch (Lucene.Net.Search.BooleanQuery.TooManyClauses) { break; } qterms++; if (maxQueryTerms > 0 && qterms >= maxQueryTerms) { break; } } return(query); }
public MultiSearcherThread(Searchable searchable, Weight weight, Filter filter, int nDocs, FieldDocSortedHitQueue hq, Sort sort, int i, int[] starts, System.String name):base(name) { this.searchable = searchable; this.weight = weight; this.filter = filter; this.nDocs = nDocs; this.hq = hq; this.i = i; this.starts = starts; this.sort = sort; }
/// <summary>Constructor to collect the top-scoring documents by using the given PQ.</summary> /// <param name="hq">the PQ to use by this instance. /// </param> protected internal TopDocCollector(PriorityQueue<ScoreDoc> hq) { this.hq = hq; }
internal TopDocCollector(int numHits, PriorityQueue<ScoreDoc> hq) { this.hq = hq; }