/// <summary> /// Pass <c>true</c> if at search time you require /// accurate counts of the dimension, i.e. how many /// hits have this dimension. /// </summary> public virtual void SetRequireDimCount(string dimName, bool v) { lock (this) { if (!fieldTypes.ContainsKey(dimName)) { var ft = new DimConfig { RequireDimCount = v }; fieldTypes[dimName] = ft; } else { fieldTypes[dimName].RequireDimCount = v; } } }
/// <summary> /// Pass <c>true</c> if this dimension may have more than /// one value per document. /// </summary> public virtual void SetMultiValued(string dimName, bool v) { lock (this) { if (!fieldTypes.ContainsKey(dimName)) { var ft = new DimConfig { IsMultiValued = v }; fieldTypes[dimName] = ft; } else { fieldTypes[dimName].IsMultiValued = v; } } }
/// <summary> /// Pass <c>true</c> if this dimension is hierarchical /// (has depth > 1 paths). /// </summary> public virtual void SetHierarchical(string dimName, bool v) { lock (this) { if (!fieldTypes.ContainsKey(dimName)) { var ft = new DimConfig { IsHierarchical = v }; fieldTypes[dimName] = ft; } else { fieldTypes[dimName].IsHierarchical = v; } } }
/// <summary> /// Specify which index field name should hold the /// ordinals for this dimension; this is only used by the /// taxonomy based facet methods. /// </summary> public virtual void SetIndexFieldName(string dimName, string indexFieldName) { UninterruptableMonitor.Enter(syncLock); try { // LUCENENET: Eliminated extra lookup by using TryGetValue instead of ContainsKey if (!fieldTypes.TryGetValue(dimName, out DimConfig fieldType)) { fieldTypes[dimName] = new DimConfig { IndexFieldName = indexFieldName }; } else { fieldType.IndexFieldName = indexFieldName; } } finally { UninterruptableMonitor.Exit(syncLock); } }
public virtual void SetRequireDimCount(string dimName, bool v) { UninterruptableMonitor.Enter(syncLock); try { // LUCENENET: Eliminated extra lookup by using TryGetValue instead of ContainsKey if (!fieldTypes.TryGetValue(dimName, out DimConfig fieldType)) { fieldTypes[dimName] = new DimConfig { RequireDimCount = v }; } else { fieldType.RequireDimCount = v; } } finally { UninterruptableMonitor.Exit(syncLock); } }
/// <summary> /// Note: if you use a counting <see cref="Facets"/> implementation, you can amortize the /// sampled counts by calling this method. Uses the <see cref="FacetsConfig"/> and /// the <see cref="IndexSearcher"/> to determine the upper bound for each facet value. /// </summary> public virtual FacetResult AmortizeFacetCounts(FacetResult res, FacetsConfig config, IndexSearcher searcher) { if (res == null || totalHits <= sampleSize) { return(res); } LabelAndValue[] fixedLabelValues = new LabelAndValue[res.LabelValues.Length]; IndexReader reader = searcher.IndexReader; DimConfig dimConfig = config.GetDimConfig(res.Dim); // +2 to prepend dimension, append child label string[] childPath = new string[res.Path.Length + 2]; childPath[0] = res.Dim; Array.Copy(res.Path, 0, childPath, 1, res.Path.Length); // reuse for (int i = 0; i < res.LabelValues.Length; i++) { childPath[res.Path.Length + 1] = res.LabelValues[i].Label; string fullPath = FacetsConfig.PathToString(childPath, childPath.Length); int max = reader.DocFreq(new Term(dimConfig.IndexFieldName, fullPath)); int correctedCount = (int)((double)res.LabelValues[i].Value / samplingRate); correctedCount = Math.Min(max, correctedCount); fixedLabelValues[i] = new LabelAndValue(res.LabelValues[i].Label, correctedCount); } // cap the total count on the total number of non-deleted documents in the reader int correctedTotalCount = (int)res.Value; if (correctedTotalCount > 0) { correctedTotalCount = Math.Min(reader.NumDocs, (int)((double)res.Value / samplingRate)); } return(new FacetResult(res.Dim, res.Path, correctedTotalCount, fixedLabelValues, res.ChildCount)); }
public override IList <FacetResult> GetAllDims(int topN) { int ord = m_children[TaxonomyReader.ROOT_ORDINAL]; List <FacetResult> results = new List <FacetResult>(); while (ord != TaxonomyReader.INVALID_ORDINAL) { string dim = m_taxoReader.GetPath(ord).Components[0]; DimConfig dimConfig = m_config.GetDimConfig(dim); if (dimConfig.IndexFieldName.Equals(m_indexFieldName)) { FacetResult result = GetTopChildren(topN, dim); if (result != null) { results.Add(result); } } ord = m_siblings[ord]; } // Sort by highest value, tie break by dim: results.Sort(BY_VALUE_THEN_DIM); return(results); }
/// <summary> /// Pass {@code true} if at search time you require /// accurate counts of the dimension, i.e. how many /// hits have this dimension. /// </summary> public virtual void SetRequireDimCount(string dimName, bool v) { lock (this) { if (!fieldTypes.ContainsKey(dimName)) { var ft = new DimConfig { RequireDimCount = v }; fieldTypes[dimName] = ft; } else { fieldTypes[dimName].RequireDimCount = v; } } }
/// <summary> /// Pass {@code true} if this dimension may have more than /// one value per document. /// </summary> public virtual void SetMultiValued(string dimName, bool v) { lock (this) { if (!fieldTypes.ContainsKey(dimName)) { var ft = new DimConfig { MultiValued = v }; fieldTypes[dimName] = ft; } else { fieldTypes[dimName].MultiValued = v; } } }
/// <summary> /// Specify which index field name should hold the /// ordinals for this dimension; this is only used by the /// taxonomy based facet methods. /// </summary> public virtual void SetIndexFieldName(string dimName, string indexFieldName) { lock (this) { if (!fieldTypes.ContainsKey(dimName)) { var ft = new DimConfig { IndexFieldName = indexFieldName }; fieldTypes[dimName] = ft; } else { fieldTypes[dimName].IndexFieldName = indexFieldName; } } }
/// <summary> /// Pass {@code true} if this dimension is hierarchical /// (has depth > 1 paths). /// </summary> public virtual void SetHierarchical(string dimName, bool v) { lock (this) { if (!fieldTypes.ContainsKey(dimName)) { var ft = new DimConfig { Hierarchical = v }; fieldTypes[dimName] = ft; } else { fieldTypes[dimName].Hierarchical = v; } } }