internal FieldQuery(Query query, IndexReader reader, bool phraseHighlight, bool fieldMatch) { this.fieldMatch = fieldMatch; // LUCENENET NOTE: LinkedHashSet cares about insertion order ISet <Query> flatQueries = new JCG.LinkedHashSet <Query>(); Flatten(query, reader, flatQueries); SaveTerms(flatQueries, reader); ICollection <Query> expandQueries = Expand(flatQueries); foreach (Query flatQuery in expandQueries) { QueryPhraseMap rootMap = GetRootMap(flatQuery); rootMap.Add(flatQuery /*, reader // LUCENENET: Never read */); if (!phraseHighlight && flatQuery is PhraseQuery pq) { if (pq.GetTerms().Length > 1) { foreach (Term term in pq.GetTerms()) { rootMap.AddTerm(term, flatQuery.Boost); } } } } }
public void Add(Query query) { if (query is TermQuery) { AddTerm(((TermQuery)query).Term.Text, query.Boost); } else if (query is PrefixQuery) { AddTerm(((PrefixQuery)query).Prefix.Text + "*", query.Boost); } else if (query is PhraseQuery) { PhraseQuery pq = (PhraseQuery)query; Term[] terms = pq.GetTerms(); HashMap <String, QueryPhraseMap> map = subMap; QueryPhraseMap qpm = null; foreach (Term term in terms) { qpm = GetOrNewMap(map, term.Text); map = qpm.subMap; } qpm.MarkTerminal(pq.Slop, pq.Boost); } else { throw new ApplicationException("query \"" + query.ToString() + "\" must be flatten first."); } }
int termOrPhraseNumber; // used for colored tag support public FieldQuery(Query query, bool phraseHighlight, bool fieldMatch) { this.fieldMatch = fieldMatch; Dictionary <Query, Query> flatQueries = new Dictionary <Query, Query>(); flatten(query, flatQueries); SaveTerms(flatQueries); Dictionary <Query, Query> expandQueries = expand(flatQueries); foreach (Query flatQuery in expandQueries.Keys) { QueryPhraseMap rootMap = getRootMap(flatQuery); rootMap.Add(flatQuery); if (!phraseHighlight && flatQuery is PhraseQuery) { PhraseQuery pq = (PhraseQuery)flatQuery; if (pq.GetTerms().Length > 1) { foreach (Term term in pq.GetTerms()) { rootMap.AddTerm(term.Text, flatQuery.Boost); } } } } }
private QueryPhraseMap GetOrNewMap(IDictionary <string, QueryPhraseMap> subMap, string term) { if (!subMap.TryGetValue(term, out QueryPhraseMap map) || map == null) { map = new QueryPhraseMap(fieldQuery); subMap[term] = map; } return(map); }
/// <returns>QueryPhraseMap</returns> public virtual QueryPhraseMap SearchPhrase(string fieldName, IList <TermInfo> phraseCandidate) { QueryPhraseMap root = GetRootMap(fieldName); if (root == null) { return(null); } return(root.SearchPhrase(phraseCandidate)); }
public QueryPhraseMap SearchPhrase(List<TermInfo> phraseCandidate) { QueryPhraseMap currMap = this; foreach (TermInfo ti in phraseCandidate) { currMap = currMap.subMap[ti.GetText()]; if (currMap == null) return null; } return currMap.IsValidTermOrPhrase(phraseCandidate) ? currMap : null; }
private QueryPhraseMap GetOrNewMap(HashMap<String, QueryPhraseMap> subMap, String term) { QueryPhraseMap map = subMap.Get(term); if (map == null) { map = new QueryPhraseMap(fieldQuery); subMap.Put(term,map); } return map; }
/// <returns>QueryPhraseMap</returns> public virtual QueryPhraseMap GetFieldTermMap(string fieldName, string term) { QueryPhraseMap rootMap = GetRootMap(fieldName); if (rootMap == null) { return(null); } rootMap.subMap.TryGetValue(term, out QueryPhraseMap result); return(result); }
public QueryPhraseMap RetrieveQueryFromSubMap(QueryPhraseMap rootMap, String term) { foreach (var kvp in rootMap.subMap) { if (StringUtils.TermStringMatch(kvp.Key, term)) { return(kvp.Value); } } return(null); }
internal QueryPhraseMap GetRootMap(Query query) { string key = GetKey(query); if (!rootMaps.TryGetValue(key, out QueryPhraseMap map) || map == null) { map = new QueryPhraseMap(this); rootMaps[key] = map; } return(map); }
public QueryPhraseMap getRootMap(Query query) { String key = GetKey(query); QueryPhraseMap map=rootMaps.Get(key); if (map == null) { map = new QueryPhraseMap(this); rootMaps.Put(key,map); } return map; }
public virtual QueryPhraseMap SearchPhrase(IList <TermInfo> phraseCandidate) { QueryPhraseMap currMap = this; foreach (TermInfo ti in phraseCandidate) { currMap.subMap.TryGetValue(ti.Text, out currMap); if (currMap == null) { return(null); } } return(currMap.IsValidTermOrPhrase(phraseCandidate) ? currMap : null); }
internal void Add(Query query /*, IndexReader reader // LUCENENET: Never read */) { if (query is TermQuery termQuery) { AddTerm(termQuery.Term, query.Boost); } else if (query is PhraseQuery pq) { Term[] terms = pq.GetTerms(); IDictionary <string, QueryPhraseMap> map = subMap; QueryPhraseMap qpm = null; foreach (Term term in terms) { qpm = GetOrNewMap(map, term.Text); map = qpm.subMap; } qpm.MarkTerminal(pq.Slop, pq.Boost); } else { throw RuntimeException.Create("query \"" + query.ToString() + "\" must be flatten first."); } }
internal void Add(Query query, IndexReader reader) { if (query is TermQuery) { AddTerm(((TermQuery)query).Term, query.Boost); } else if (query is PhraseQuery) { PhraseQuery pq = (PhraseQuery)query; Term[] terms = pq.GetTerms(); IDictionary <string, QueryPhraseMap> map = subMap; QueryPhraseMap qpm = null; foreach (Term term in terms) { qpm = GetOrNewMap(map, term.Text()); map = qpm.subMap; } qpm.MarkTerminal(pq.Slop, pq.Boost); } else { throw new Exception("query \"" + query.ToString() + "\" must be flatten first."); } }
public QueryPhraseMap getRootMap(Query query) { String key = GetKey(query); QueryPhraseMap map = rootMaps.Get(key); if (map == null) { map = new QueryPhraseMap(this); rootMaps.Put(key, map); } return map; }
/** * * @param fieldName * @param phraseCandidate * @return QueryPhraseMap */ public QueryPhraseMap SearchPhrase(String fieldName, List<TermInfo> phraseCandidate) { QueryPhraseMap root = GetRootMap(fieldName); if (root == null) return null; return root.SearchPhrase(phraseCandidate); }
internal void AddTerm(Term term, float boost) { QueryPhraseMap map = GetOrNewMap(subMap, term.Text); map.MarkTerminal(boost); }
/* * * <param name="fieldName"></param> * <param name="term"></param> * <returns>QueryPhraseMap</returns> */ public QueryPhraseMap GetFieldTermMap(String fieldName, String term) { QueryPhraseMap rootMap = GetRootMap(fieldName); return(rootMap == null ? null : RetrieveQueryFromSubMap(rootMap, term)); }
public void AddTerm(String termText, float boost) { QueryPhraseMap map = GetOrNewMap(subMap, termText); map.MarkTerminal(boost); }
/** * * @param fieldName * @param term * @return QueryPhraseMap */ public QueryPhraseMap GetFieldTermMap(String fieldName, String term) { QueryPhraseMap rootMap = GetRootMap(fieldName); return rootMap == null ? null : rootMap.subMap.Get(term); }
private QueryPhraseMap GetOrNewMap(HashMap<String, QueryPhraseMap> subMap, String term) { QueryPhraseMap map = subMap.Get(term); if (map == null) { map = new QueryPhraseMap(fieldQuery); subMap.Put(term, map); } return map; }
public QueryPhraseMap RetrieveQueryFromSubMap(QueryPhraseMap rootMap, String term) { foreach (var kvp in rootMap.subMap) { if (StringUtils.TermStringMatch(kvp.Key, term)) return kvp.Value; } return null; }