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


C# Document.Fields方法代码示例

本文整理汇总了C#中Lucene.Net.Documents.Document.Fields方法的典型用法代码示例。如果您正苦于以下问题:C# Document.Fields方法的具体用法?C# Document.Fields怎么用?C# Document.Fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Documents.Document的用法示例。


在下文中一共展示了Document.Fields方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DocumentToStoredInfo

		public StoredInfo DocumentToStoredInfo (Document doc)
		{
			int count = 0;
			StoredInfo info = new StoredInfo ();

			info.Uri = GetUriFromDocument (doc);

			foreach (Field f in doc.Fields ()) {
				Property prop = GetPropertyFromDocument (f, doc, false);
				if (prop == null)
					continue;

				switch (prop.Key) {
				case "fixme:indexDateTime":
					info.LastIndex = StringFu.StringToDateTime (prop.Value);
					count++;
					break;
				case "fixme:fullyIndexed":
					info.FullyIndexed = Convert.ToBoolean (prop.Value);
					count++;
					break;
				}
				
				if (count == 2)
					break;
			}

			return info;
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:29,代码来源:LuceneAccess.cs

示例2: DocumentToNameInfo

		private NameInfo DocumentToNameInfo (Document doc)
		{
			NameInfo info;
			info = new NameInfo ();

			string str;
			str = doc.Get ("Uri");
			info.Id = GuidFu.FromUriString (str);

			bool have_name = false;
			bool have_parent_id = false;
			bool have_is_dir = false;

			foreach (Field f in doc.Fields ()) {
				Property prop;
				prop = GetPropertyFromDocument (f, doc, false);
				if (prop == null)
					continue;

				switch (prop.Key) {
					
				case Property.ExactFilenamePropKey:
					info.Name = prop.Value;
					have_name = true;
					break;
					
				case Property.ParentDirUriPropKey:
					info.ParentId = GuidFu.FromUriString (prop.Value);
					have_parent_id = true;
					break;

				case Property.IsDirectoryPropKey:
					info.IsDirectory = (prop.Value == "true");
					have_is_dir = true;
					break;
				}

				if (have_name && have_parent_id && have_is_dir)
					break;
			}

			return info;
		}
开发者ID:zweib730,项目名称:beagrep,代码行数:43,代码来源:InternalUriManager.cs

示例3: 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

示例4: MergeDocuments

                static protected Document MergeDocuments (Document doc,
                                                          Document prop_change_doc)
                {
                        if (doc == null)
                                return prop_change_doc;

                        if (prop_change_doc == null)
                                return doc;

                        foreach (Field f in prop_change_doc.Fields ()) {
                                Property prop = GetPropertyFromDocument (f, prop_change_doc, false);

                                if (prop != null && prop.IsPersistent) {
                                        Log.Debug ("Moving old persistent prop '{0}' = '{1}' forward", prop.Key, prop.Value);
                                        AddPropertyToDocument (prop, doc);
                                }
                        }

                        return doc;
                }
开发者ID:zweib730,项目名称:beagrep,代码行数:20,代码来源:LuceneCommon.cs

示例5: RewriteDocument

                static protected Document RewriteDocument (Document old_secondary_doc,
                                                           Indexable prop_only_indexable)
                {
                        Hashtable seen_props;
                        seen_props = new Hashtable ();

                        Document new_doc;
                        new_doc = new Document ();

                        Field uri_f;
                        uri_f = new Field ("Uri", UriFu.UriToEscapedString (prop_only_indexable.Uri), Field.Store.YES, Field.Index.NO_NORMS);
                        new_doc.Add (uri_f);

                        Logger.Log.Debug ("Rewriting {0}", prop_only_indexable.DisplayUri);

                        if (prop_only_indexable.ParentUri != null) {
                                uri_f = new Field ("ParentUri", UriFu.UriToEscapedString (prop_only_indexable.ParentUri), Field.Store.YES, Field.Index.NO_NORMS);
                                new_doc.Add (uri_f);
                                Logger.Log.Debug ("Parent Uri {0}", prop_only_indexable.ParentUri);
                        }

                        // Add the new properties to the new document.  To
                        // delete a property, set the Value to null... then it
                        // will be added to seen_props (so the old value will
                        // be ignored below), but AddPropertyToDocument will
                        // return w/o doing anything.
                        foreach (Property prop in prop_only_indexable.Properties) {
                                seen_props [prop.Key] = prop;

                                // Don't add properties that are empty; they
                                // essentially mean "reset this property"
                                if (prop.Value == String.Empty) {
                                        Log.Debug ("Resetting prop '{0}'", prop.Key);
                                        continue;
                                }

                                AddPropertyToDocument (prop, new_doc);
                                Logger.Log.Debug ("New prop '{0}' = '{1}'", prop.Key, prop.Value);
                        }

                        // Copy the other properties from the old document to the
                        // new one, skipping any properties that we got new values
                        // for out of the Indexable.
                        if (old_secondary_doc != null) {
                                foreach (Field f in old_secondary_doc.Fields ()) {
                                        Property prop;
                                        prop = GetPropertyFromDocument (f, old_secondary_doc, false);
                                        if (prop != null && ! seen_props.Contains (prop.Key)) {
                                                Logger.Log.Debug ("Old prop '{0}' = '{1}'", prop.Key, prop.Value);
                                                AddPropertyToDocument (prop, new_doc);
                                        }
                                }
                        }

                        return new_doc;
                }
开发者ID:zweib730,项目名称:beagrep,代码行数:56,代码来源:LuceneCommon.cs

示例6: AddPropertiesToHit

 static protected void AddPropertiesToHit (Hit hit, Document doc, bool from_primary_index)
 {
         Property prop;
         foreach (Field f in doc.Fields ()) {
                 prop = GetPropertyFromDocument (f, doc, from_primary_index);
                 if (prop != null)
                         hit.AddProperty (prop);
         }
 }
开发者ID:zweib730,项目名称:beagrep,代码行数:9,代码来源:LuceneCommon.cs

示例7: DocumentToDirent

                static private Dirent DocumentToDirent (Document doc)
                {
                        string path;
                        bool is_dir = false;

                        path = doc.Get ("Uri");

                        string prop_key = "prop:k:" + Property.IsDirectoryPropKey;
                        foreach (Field f in doc.Fields ()) {
                                if (f.Name () != prop_key)
                                        continue;

                                // Format of fields: from LuceneCommon.cs:AddPropertyToDocument
                                is_dir = (f.StringValue ().Substring (3) == "true");
                                break;
                        }

                        //Logger.Log.Debug ("Found: " + path + " (" + is_dir + ")");
                        return new Dirent (path, is_dir);
                }
开发者ID:zweib730,项目名称:beagrep,代码行数:20,代码来源:BuildIndex.cs

示例8: TranslateDocument

 protected IndexDocument TranslateDocument(Document doc)
 {
     IndexDocument document = new IndexDocument();
     foreach (Field f in doc.Fields())
     {
         FieldType type = FieldType.Keyword;
         if (f.IsIndexed() && f.IsStored() && f.IsTokenized())
         {
             type = FieldType.Text;
         }
         else if (f.IsIndexed() && f.IsStored() && !f.IsTokenized())
         {
             type = FieldType.Keyword;
         }
         else if (f.IsIndexed() && !f.IsStored() && f.IsTokenized())
         {
             type = FieldType.TextUnStored;
         }
         else if (f.IsIndexed() && !f.IsStored() && !f.IsTokenized())
         {
             type = FieldType.UnStored;
         }
         else if (!f.IsIndexed() && f.IsStored())
         {
             type = FieldType.UnIndexed;
         }
         document.AddField(type, f.Name(), f.StringValue());
     }
     return document;
 }
开发者ID:mrkurt,项目名称:mubble-old,代码行数:30,代码来源:Lucene.cs


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