public virtual string GetUnicodeLocaleType(string unicodeLocaleKey) { string result; _keywords.TryGetValue(unicodeLocaleKey, out result); return(result); }
/// <summary> /// Check the hits for duplicates. /// </summary> private void CheckHits(ScoreDoc[] hits, string prefix) { if (hits != null) { IDictionary <int?, int?> idMap = new JCG.SortedDictionary <int?, int?>(); for (int docnum = 0; docnum < hits.Length; ++docnum) { int?luceneId = null; luceneId = Convert.ToInt32(hits[docnum].Doc); if (idMap.TryGetValue(luceneId, out int?value)) { StringBuilder message = new StringBuilder(prefix); message.Append("Duplicate key for hit index = "); message.Append(docnum); message.Append(", previous index = "); message.Append(value.ToString()); message.Append(", Lucene ID = "); message.Append(luceneId); Log(message.ToString()); } else { idMap[luceneId] = Convert.ToInt32(docnum); } } } }
public override Terms GetTerms(string field) { UninterruptableMonitor.Enter(this); try { if (!termsCache.TryGetValue(field, out SimpleTextTerms terms) || terms is null) { if (!fields.TryGetValue(field, out long fp)) { return(null); } else { terms = new SimpleTextTerms(this, field, fp, maxDoc); termsCache[field] = terms; } } return(terms); } finally { UninterruptableMonitor.Exit(this); } }
public virtual Query Build(IQueryNode queryNode) { MultiPhraseQueryNode phraseNode = (MultiPhraseQueryNode)queryNode; MultiPhraseQuery phraseQuery = new MultiPhraseQuery(); IList <IQueryNode> children = phraseNode.GetChildren(); if (children != null) { IDictionary <int?, List <Term> > positionTermMap = new JCG.SortedDictionary <int?, List <Term> >(); foreach (IQueryNode child in children) { FieldQueryNode termNode = (FieldQueryNode)child; TermQuery termQuery = (TermQuery)termNode .GetTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID); List <Term> termList; if (!positionTermMap.TryGetValue(termNode.PositionIncrement, out termList) || termList == null) { termList = new List <Term>(); positionTermMap[termNode.PositionIncrement] = termList; } termList.Add(termQuery.Term); } foreach (int positionIncrement in positionTermMap.Keys) { List <Term> termList = positionTermMap[positionIncrement]; phraseQuery.Add(termList.ToArray(/*new Term[termList.size()]*/), positionIncrement); } } return(phraseQuery); }