/// <summary> /// /// </summary> /// <param name="value">This value should be one of the user-specified ranges for this Facet Count Collector. Else an /// ArgumentException will be raised</param> /// <returns>The BrowseFacet corresponding to the range value</returns> public virtual BrowseFacet GetFacet(string value) { if (m_predefinedRanges != null) { int index = 0; if ((index = m_predefinedRanges.IndexOf(value)) != -1) { BrowseFacet choice = new BrowseFacet(); choice.FacetValueHitCount = m_count.Get(index); choice.Value = value; return(choice); } else { // user specified an unknown range value. the overhead to calculate the count for an unknown range value is high, // in the sense it requires to go through each docid in the index. Till we get a better solution, this operation is // unsupported throw new ArgumentException("The value argument is not one of the user-specified ranges"); } } else { throw new ArgumentException("There are no user-specified ranges for this Facet Count Collector object"); } }
/// <summary> /// get the facet of one particular bucket /// </summary> /// <param name="bucketValue"></param> /// <returns></returns> public virtual BrowseFacet GetFacet(string bucketValue) { int index = m_bucketValues.IndexOf(bucketValue); if (index < 0) { return(new BrowseFacet(bucketValue, 0)); } BigSegmentedArray counts = GetCollapsedCounts(); return(new BrowseFacet(bucketValue, counts.Get(index))); }
public void TestTermStringListAddCorrectOrder() { TermStringList tsl1 = new TermStringList(); tsl1.Add(null); tsl1.Add(""); try { tsl1.Add("m"); tsl1.Add("s"); tsl1.Add("t"); } catch (Exception e) { Assert.False(e.Message.Contains("ascending order"), "There should NOT be an exception and the message contains ascending order"); return; } tsl1.Seal(); Assert.AreEqual(1, tsl1.IndexOf(""), "Should skip index 0 which is used for dummy null"); }
public void TestTermStringListAddCorrectOrder() { TermStringList tsl1 = new TermStringList(); tsl1.Add(null); tsl1.Add(""); try { tsl1.Add("m"); tsl1.Add("s"); tsl1.Add("t"); } catch (Exception e) { Assert.False(e.Message.Contains("ascending order"), "There should NOT be an exception and the message contains ascending order"); return; } tsl1.Seal(); Assert.AreEqual(1, tsl1.IndexOf(""), "Should skip index 0 which is used for dummy null"); }