/// <summary> /// Adds a new <see cref="SortedSetDocValuesFacetField"/>. /// </summary> /// <remarks> /// Add a <see cref="SortedSetDocValuesFacetField"/> to your <see cref="Documents.Document"/> for every facet /// label to be indexed via <see cref="Index.SortedSetDocValues"/>. /// </remarks> /// <param name="document">This <see cref="Document"/>.</param> /// <param name="dim">Dimension for this field.</param> /// <param name="label">Label for this field.</param> /// <returns>The field that was added to this <see cref="Document"/>.</returns> public static SortedSetDocValuesFacetField AddSortedSetDocValuesFacetField(this Document document, string dim, string label) { var field = new SortedSetDocValuesFacetField(dim, label); document.Add(field); return(field); }
public void TestAddSortedSetDocValuesFacetField() { SortedSetDocValuesFacetField field = null; AssertDocumentExtensionAddsToDocument(document => field = document.AddSortedSetDocValuesFacetField("theDim", "theLabel")); Assert.AreEqual("theDim", field.Dim); Assert.AreEqual("theLabel", field.Label); }
/// <summary> /// Adds a new <see cref="SortedSetDocValuesFacetField"/>. /// </summary> /// <remarks> /// Add a <see cref="SortedSetDocValuesFacetField"/> to your <see cref="Documents.Document"/> for every facet /// label to be indexed via <see cref="Index.SortedSetDocValues"/>. /// </remarks> /// <param name="document">This <see cref="Document"/>.</param> /// <param name="dim">Dimension for this field.</param> /// <param name="label">Label for this field.</param> /// <returns>The field that was added to this <see cref="Document"/>.</returns> /// <exception cref="ArgumentNullException">This <paramref name="document"/> is <c>null</c>. </exception> public static SortedSetDocValuesFacetField AddSortedSetDocValuesFacetField(this Document document, string dim, string label) { if (document is null) { throw new ArgumentNullException(nameof(document)); } var field = new SortedSetDocValuesFacetField(dim, label); document.Add(field); return(field); }
public virtual void TestEmptyNullComponents() { // LUCENE-4724: CategoryPath should not allow empty or null components string[][] components_tests = new string[][] { new string[] { "", "test" }, // empty in the beginning new string[] { "test", "" }, // empty in the end new string[] { "test", "", "foo" }, // empty in the middle new string[] { null, "test" }, // null at the beginning new string[] { "test", null }, // null in the end new string[] { "test", null, "foo" } // null in the middle }; foreach (string[] components in components_tests) { try { Assert.IsNotNull(new FacetLabel(components)); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new FacetField("dim", components); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new AssociationFacetField(new BytesRef(), "dim", components); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new Int32AssociationFacetField(17, "dim", components); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SingleAssociationFacetField(17.0f, "dim", components); fail("empty or null components should not be allowed: " + Arrays.ToString(components)); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } } try { _ = new FacetField(null, new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new FacetField("", new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new Int32AssociationFacetField(17, null, new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new Int32AssociationFacetField(17, "", new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SingleAssociationFacetField(17.0f, null, new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SingleAssociationFacetField(17.0f, "", new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new AssociationFacetField(new BytesRef(), null, new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new AssociationFacetField(new BytesRef(), "", new string[] { "abc" }); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SortedSetDocValuesFacetField(null, "abc"); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SortedSetDocValuesFacetField("", "abc"); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SortedSetDocValuesFacetField("dim", null); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } try { _ = new SortedSetDocValuesFacetField("dim", ""); fail("empty or null components should not be allowed"); } catch (Exception e) when(e.IsIllegalArgumentException()) { // expected } }