Beispiel #1
0
        /// <summary>
        /// Adds a new <see cref="ICUCollationDocValuesField"/>.
        /// <para/>
        /// NOTE: you should not create a new one for each document, instead
        /// just make one and reuse it during your indexing process, setting
        /// the value via <see cref="ICUCollationDocValuesField.SetStringValue(string)"/>.
        /// </summary>
        /// <param name="document">This <see cref="Document"/>.</param>
        /// <param name="name">Field name.</param>
        /// <param name="collator">Collator for generating collation keys.</param>
        /// <returns>The field that was added to this <see cref="Document"/>.</returns>
        public static ICUCollationDocValuesField AddICUCollationDocValuesField(this Document document, string name, Collator collator)
        {
            var field = new ICUCollationDocValuesField(name, collator);

            document.Add(field);
            return(field);
        }
        public void TestAddICUCollationDocValuesField()
        {
            ICUCollationDocValuesField field = null;
            Collator collator = Collator.GetInstance(new CultureInfo("en"));

            AssertDocumentExtensionAddsToDocument(document => field = document.AddICUCollationDocValuesField("theName", collator));
            Assert.AreEqual("theName", field.Name);
            Assert.AreEqual(collator, field.collator); // Collator is cloned, so we don't expect them to be the same instance
        }
Beispiel #3
0
        /// <summary>
        /// Adds a new <see cref="ICUCollationDocValuesField"/>.
        /// <para/>
        /// NOTE: you should not create a new one for each document, instead
        /// just make one and reuse it during your indexing process, setting
        /// the value via <see cref="ICUCollationDocValuesField.SetStringValue(string)"/>.
        /// </summary>
        /// <param name="document">This <see cref="Document"/>.</param>
        /// <param name="name">Field name.</param>
        /// <param name="collator">Collator for generating collation keys.</param>
        /// <returns>The field that was added to this <see cref="Document"/>.</returns>
        /// <exception cref="ArgumentNullException">This <paramref name="document"/>, <paramref name="name"/> or <paramref name="collator"/> is <c>null</c>. </exception>
        public static ICUCollationDocValuesField AddICUCollationDocValuesField(this Document document, string name, Collator collator)
        {
            if (document is null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            var field = new ICUCollationDocValuesField(name, collator);

            document.Add(field);
            return(field);
        }