当前位置: 首页>>代码示例>>C#>>正文


C# Document.RemoveFields方法代码示例

本文整理汇总了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);
                    }
                }
            }
        }
开发者ID:yao-yi,项目名称:BoboBrowse.Net,代码行数:19,代码来源:DataDigester.cs

示例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]);
                    }
                }
            }
        }
开发者ID:NightOwl888,项目名称:Bobo-Browse.Net,代码行数:20,代码来源:DataDigester.cs

示例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);
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:45,代码来源:TestDocument.cs

示例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);
                }
开发者ID:zweib730,项目名称:beagrep,代码行数:27,代码来源:LuceneCommon.cs


注:本文中的Lucene.Net.Documents.Document.RemoveFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。