本文整理汇总了C#中Lucene.Net.Documents.Document.RemoveFields方法的典型用法代码示例。如果您正苦于以下问题:C# Document.RemoveFields方法的具体用法?C# Document.RemoveFields怎么用?C# Document.RemoveFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Documents.Document
的用法示例。
在下文中一共展示了Document.RemoveFields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateDocument
public static void PopulateDocument(Document doc, IEnumerable<IFacetHandler> handlers)
{
StringBuilder tokenBuffer = new StringBuilder();
foreach (var handler in handlers)
{
string name = handler.Name;
string[] values = doc.GetValues(name);
if (values != null)
{
doc.RemoveFields(name);
foreach (string value in values)
{
doc.Add(new Field(name, value, Field.Store.NO, Field.Index.NOT_ANALYZED));
tokenBuffer.Append(' ').Append(value);
}
}
}
}
示例2: PopulateDocument
public static void PopulateDocument(Document doc, FieldConfiguration fConf)
{
var fields = fConf.GetFieldNames();
var tokenBuffer = new StringBuilder();
for (int i = 0; i < fields.Length; ++i)
{
var values = doc.GetValues(fields[i]);
if (values != null)
{
doc.RemoveFields(fields[i]);
for (int k = 0; k < values.Length; ++k)
{
doc.Add(new Field(fields[i], values[i], Field.Store.NO, Field.Index.NOT_ANALYZED));
tokenBuffer.Append(" ").Append(values[i]);
}
}
}
}
示例3: TestBinaryField
public virtual void TestBinaryField()
{
Document doc = new Document();
Fieldable stringFld = new Field("string", binaryVal, Field.Store.YES, Field.Index.NO);
Fieldable binaryFld = new Field("binary", System.Text.UTF8Encoding.UTF8.GetBytes(binaryVal), Field.Store.YES);
Fieldable binaryFld2 = new Field("binary", System.Text.UTF8Encoding.UTF8.GetBytes(binaryVal2), Field.Store.YES);
doc.Add(stringFld);
doc.Add(binaryFld);
Assert.AreEqual(2, doc.fields_ForNUnit.Count);
Assert.IsTrue(binaryFld.IsBinary());
Assert.IsTrue(binaryFld.IsStored());
Assert.IsFalse(binaryFld.IsIndexed());
Assert.IsFalse(binaryFld.IsTokenized());
System.String binaryTest = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(doc.GetBinaryValue("binary")));
Assert.IsTrue(binaryTest.Equals(binaryVal));
System.String stringTest = doc.Get("string");
Assert.IsTrue(binaryTest.Equals(stringTest));
doc.Add(binaryFld2);
Assert.AreEqual(3, doc.fields_ForNUnit.Count);
byte[][] binaryTests = doc.GetBinaryValues("binary");
Assert.AreEqual(2, binaryTests.Length);
binaryTest = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(binaryTests[0]));
System.String binaryTest2 = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(binaryTests[1]));
Assert.IsFalse(binaryTest.Equals(binaryTest2));
Assert.IsTrue(binaryTest.Equals(binaryVal));
Assert.IsTrue(binaryTest2.Equals(binaryVal2));
doc.RemoveField("string");
Assert.AreEqual(2, doc.fields_ForNUnit.Count);
doc.RemoveFields("binary");
Assert.AreEqual(0, doc.fields_ForNUnit.Count);
}
示例4: AddFieldProperies
// Add a new field with whitespace separated names of the existing fields
static protected void AddFieldProperies (Document doc)
{
const string Separator = " ";
StringBuilder sb = new StringBuilder ();
bool seen_properties = false;
foreach (Fieldable f in doc.Fields ()) {
if (f.Name () == "Properties") {
seen_properties = true;
continue;
}
sb.Append (f.Name ());
sb.Append (Separator);
}
if (sb.Length > 0)
sb.Length -= Separator.Length;
if (seen_properties)
doc.RemoveFields ("Properties");
Field field = new Field ("Properties", sb.ToString (), Field.Store.NO, Field.Index.TOKENIZED);
doc.Add (field);
}