Beispiel #1
0
		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;
			}
		}
Beispiel #2
0
        public override bool Equals(System.Object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (!base.Equals(obj))
            {
                return(false);
            }
            if (GetType() != obj.GetType())
            {
                return(false);
            }
            FuzzyQuery other = (FuzzyQuery)obj;

            if (BitConverter.ToInt32(BitConverter.GetBytes(minimumSimilarity), 0) != BitConverter.ToInt32(BitConverter.GetBytes(other.minimumSimilarity), 0))
            {
                return(false);
            }
            if (prefixLength != other.prefixLength)
            {
                return(false);
            }
            if (term == null)
            {
                if (other.term != null)
                {
                    return(false);
                }
            }
            else if (!term.Equals(other.term))
            {
                return(false);
            }
            return(true);
        }