public Result Search (string term, int count, int start) { try { term = term.ToLower (); Term htTerm = new Term ("hottext", term); Query qq1 = new FuzzyQuery (htTerm); Query qq2 = new TermQuery (htTerm); qq2.SetBoost (10f); Query qq3 = new PrefixQuery (htTerm); qq3.SetBoost (10f); DisjunctionMaxQuery q1 = new DisjunctionMaxQuery (0f); q1.Add (qq1); q1.Add (qq2); q1.Add (qq3); Query q2 = new TermQuery (new Term ("text", term)); q2.SetBoost (3f); Query q3 = new TermQuery (new Term ("examples", term)); q3.SetBoost (3f); DisjunctionMaxQuery q = new DisjunctionMaxQuery (0f); q.Add (q1); q.Add (q2); q.Add (q3); TopDocs top = SearchInternal (q, count, start); Result r = new Result (term, searcher, top.ScoreDocs); Results.Add (r); return r; } catch (IOException) { Console.WriteLine ("No index in {0}", dir); return null; } }
protected internal System.Collections.ArrayList weights = new System.Collections.ArrayList(); // The Weight's for our subqueries, in 1-1 correspondence with disjuncts /* Construct the Weight for this Query searched by searcher. Recursively construct subquery weights. */ public DisjunctionMaxWeight(DisjunctionMaxQuery enclosingInstance, Searcher searcher) { InitBlock(enclosingInstance); this.similarity = searcher.GetSimilarity(); for (System.Collections.IEnumerator iter = Enclosing_Instance.disjuncts.GetEnumerator(); iter.MoveNext(); ) { weights.Add(((Query) iter.Current).CreateWeight(searcher)); } }
private void InitBlock(DisjunctionMaxQuery enclosingInstance) { this.enclosingInstance = enclosingInstance; }
public Result FastSearch (string term, int number) { try { term = term.ToLower (); Query q1 = new TermQuery (new Term ("hottext", term)); Query q2 = new PrefixQuery (new Term ("hottext", term)); q2.SetBoost (0.5f); DisjunctionMaxQuery q = new DisjunctionMaxQuery (0f); q.Add (q1); q.Add (q2); TopDocs top = searcher.Search (q, number); return new Result (term, searcher, top.ScoreDocs); } catch (IOException) { Console.WriteLine ("No index in {0}", dir); return null; } }