//fieldname MUST be interned prior to this call private static void GetTerms(Query query, System.Collections.Hashtable terms, bool prohibited, System.String fieldName) { try { if (query is BooleanQuery) { GetTermsFromBooleanQuery((BooleanQuery)query, terms, prohibited, fieldName); } else if (query is FilteredQuery) { GetTermsFromFilteredQuery((FilteredQuery)query, terms, prohibited, fieldName); } else { System.Collections.Hashtable nonWeightedTerms = new System.Collections.Hashtable(); query.ExtractTerms(nonWeightedTerms); System.Collections.IDictionaryEnumerator iter = nonWeightedTerms.GetEnumerator(); while (iter.MoveNext()) { Term term = (Term)iter.Value; if ((fieldName == null) || (term.Field() == fieldName)) { WeightedTerm temp = new WeightedTerm(query.GetBoost(), term.Text()); terms.Add(temp, temp); } } } } catch (System.NotSupportedException ignore) { //this is non-fatal for our purposes } }
/*(non-Javadoc) @see Lucene.Net.Search.Query#extractTerms(java.util.Set) */ public override void ExtractTerms(System.Collections.Hashtable terms) { subQuery.ExtractTerms(terms); for (int i = 0; i < valSrcQueries.Length; i++) { valSrcQueries[i].ExtractTerms(terms); } }
/*(non-Javadoc) <see cref="Lucene.Net.Search.Query.extractTerms(java.util.Set) */ public override void ExtractTerms(System.Collections.Generic.ISet <Term> terms) { subQuery.ExtractTerms(terms); for (int i = 0; i < valSrcQueries.Length; i++) { valSrcQueries[i].ExtractTerms(terms); } }
/*(non-Javadoc) @see Lucene.Net.Search.Query#extractTerms(java.util.Set) */ public override void ExtractTerms(ICollection <Lucene.Net.Index.Term> terms) { subQuery.ExtractTerms(terms); for (int i = 0; i < valSrcQueries.Length; i++) { valSrcQueries[i].ExtractTerms(terms); } }
public virtual void TestRewrite2() { SpanQuery q1 = new SpanTermQuery(new Term("last", "smith")); SpanQuery q2 = new SpanTermQuery(new Term("last", "jones")); SpanQuery q = new SpanNearQuery(new SpanQuery[] { q1, new FieldMaskingSpanQuery(q2, "last") }, 1, true); Query qr = searcher.Rewrite(q); QueryUtils.CheckEqual(q, qr); System.Collections.Hashtable set_Renamed = new System.Collections.Hashtable(); qr.ExtractTerms(set_Renamed); Assert.AreEqual(2, set_Renamed.Count); }
//fieldname MUST be interned prior to this call private static void GetTerms(Query query, System.Collections.Hashtable terms, bool prohibited, System.String fieldName) { try { if (query is BooleanQuery) GetTermsFromBooleanQuery((BooleanQuery) query, terms, prohibited, fieldName); else if (query is FilteredQuery) GetTermsFromFilteredQuery((FilteredQuery) query, terms, prohibited, fieldName); else { System.Collections.Hashtable nonWeightedTerms = new System.Collections.Hashtable(); query.ExtractTerms(nonWeightedTerms); System.Collections.IDictionaryEnumerator iter = nonWeightedTerms.GetEnumerator(); while (iter.MoveNext()) { Term term = (Term)iter.Value; if ((fieldName == null) || (term.Field() == fieldName)) { WeightedTerm temp = new WeightedTerm(query.GetBoost(), term.Text()); terms.Add(temp, temp); } } } } catch (System.NotSupportedException ignore) { //this is non-fatal for our purposes } }