public virtual Query VisitTermQuery(TermQuery termq) { var term = termq.GetTerm(); var visited = VisitTerm(term); if (term == visited) return termq; return new TermQuery(visited); }
public override Query VisitTermQuery(TermQuery termq) { var term = termq.GetTerm(); _text.Append(term.Field()); _text.Append(":"); _text.Append(GetTermText(term)); _text.Append(BoostToString(termq.GetBoost())); return base.VisitTermQuery(termq); }
public override Query VisitTermQuery(TermQuery termq) { var term = termq.GetTerm(); var visited = VisitTerm(term); if (term == visited) return termq; if (visited == null) return null; return new TermQuery(visited); }
public virtual Query VisitTermQuery(TermQuery termq) { var term = termq.GetTerm(); var visited = VisitTerm(term); if (term == visited) { return(termq); } return(new TermQuery(visited)); }
public void TestBoostFactor() { Hashtable originalValues = GetOriginalValues(); MoreLikeThis mlt = new MoreLikeThis( reader); mlt.SetMinDocFreq(1); mlt.SetMinTermFreq(1); mlt.SetMinWordLen(1); mlt.SetFieldNames(new String[] { "text" }); mlt.SetBoost(true); // this mean that every term boost factor will be multiplied by this // number float boostFactor = 5; mlt.SetBoostFactor(boostFactor); BooleanQuery query = (BooleanQuery)mlt.Like(new System.IO.StringReader("lucene release")); IList clauses = query.Clauses(); Assert.AreEqual(originalValues.Count, clauses.Count, "Expected " + originalValues.Count + " clauses."); for (int i = 0; i < clauses.Count; i++) { BooleanClause clause = (BooleanClause)clauses[i]; TermQuery tq = (TermQuery)clause.GetQuery(); float termBoost = (float)originalValues[tq.GetTerm().Text()]; Assert.IsNotNull(termBoost, "Expected term " + tq.GetTerm().Text()); float totalBoost = termBoost * boostFactor; Assert.AreEqual(totalBoost, tq.GetBoost(), 0.0001, "Expected boost of " + totalBoost + " for term '" + tq.GetTerm().Text() + "' got " + tq.GetBoost()); } }
public override Query VisitTermQuery(TermQuery termq) { var term = termq.GetTerm(); var visited = VisitTerm(term); if (term == visited) { return(termq); } if (visited == null) { return(null); } return(new TermQuery(visited)); }
private Hashtable GetOriginalValues() { Hashtable originalValues = new Hashtable(); MoreLikeThis mlt = new MoreLikeThis(reader); mlt.SetMinDocFreq(1); mlt.SetMinTermFreq(1); mlt.SetMinWordLen(1); mlt.SetFieldNames(new String[] { "text" }); mlt.SetBoost(true); BooleanQuery query = (BooleanQuery)mlt.Like(new System.IO.StringReader("lucene release")); IList clauses = query.Clauses(); for (int i = 0; i < clauses.Count; i++) { BooleanClause clause = (BooleanClause)clauses[i]; TermQuery tq = (TermQuery)clause.GetQuery(); originalValues.Add(tq.GetTerm().Text(), tq.GetBoost()); } return(originalValues); }