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


C# Document.GetFieldable方法代码示例

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


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

示例1: CopyToDocument

        public void CopyToDocument()
        {
            CustomValueType = new SampleValueType {TheValue = 1.34d};
            var mapper = CreateMapper();

            var doc = new Document();

            mapper.CopyToDocument(this, doc);

            Assert.That(doc.GetFieldable("CustomValueType").TokenStreamValue.ToString(), Is.EqualTo("(numeric,valSize=64,precisionStep=4)"));
            Assert.That(doc.GetFieldable("CustomValueType").StringValue, Is.EqualTo(CustomValueType.TheValue.ToString()));
        }
开发者ID:sscctech,项目名称:Lucene.Net.Linq,代码行数:12,代码来源:FieldMappingInfoBuilderNumericFieldTests.cs

示例2: CopyToDocument

        public void CopyToDocument()
        {
            TimeStamp = new DateTime(2012, 4, 23);

            var mapper = CreateMapper();

            var doc = new Document();

            mapper.CopyToDocument(this, doc);

            Assert.That(doc.GetFieldable("TimeStamp").TokenStreamValue().ToString(), Is.EqualTo("(numeric,valSize=64,precisionStep=4)"));
            Assert.That(doc.GetFieldable("TimeStamp").StringValue(), Is.EqualTo(TimeStamp.ToUniversalTime().Ticks.ToString()));
        }
开发者ID:johnculviner,项目名称:Lucene.Net.Linq,代码行数:13,代码来源:FieldMappingInfoBuilderNumericDateTimeTests.cs

示例3: CopyToDocument

        public void CopyToDocument()
        {
            TimeStampOffset = new DateTimeOffset(new DateTime(2012, 4, 23), TimeSpan.Zero);

            var mapper = CreateMapper();

            var doc = new Document();

            mapper.CopyToDocument(this, doc);

            Assert.That(doc.GetFieldable("TimeStampOffset").TokenStreamValue.ToString(), Is.EqualTo("(numeric,valSize=64,precisionStep=4)"));
            Assert.That(doc.GetFieldable("TimeStampOffset").StringValue, Is.EqualTo(TimeStampOffset.Value.UtcTicks.ToString()));
        }
开发者ID:benjaminramey,项目名称:Lucene.Net.Linq,代码行数:13,代码来源:FieldMappingInfoBuilderNumericDateTimeOffsetTests.cs

示例4: FromDocument

 public static IndexDocumentData FromDocument(Document doc)
 {
     return new IndexDocumentData()
     {
         Package = PackageJson.FromJson(JObject.Parse(doc.GetField("Data").StringValue)),
         Checksum = Int32.Parse(doc.GetFieldable("Checksum").StringValue),
         Feeds = doc.GetFields("CuratedFeed").Select(f => f.StringValue).ToList()
     };
 }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:9,代码来源:IndexDocumentData.cs

示例5: GetIdTerm

        internal static Term GetIdTerm(Document document)
        {
            var versionID =
                 NumericUtils.IntToPrefixCoded(Int32.Parse((string)document.GetFieldable(LuceneManager.KeyFieldName).StringValue()));
            if (string.IsNullOrEmpty(versionID))
                throw new ApplicationException("VersionID field missing");

            var term = new Term(LuceneManager.KeyFieldName, versionID);
            return term;
        }
开发者ID:jhuntsman,项目名称:FlexNet,代码行数:10,代码来源:UpdateDocumentActivity.cs

示例6: UsesPrecisionStep

        public void UsesPrecisionStep()
        {
            mapper = new NumericReflectionFieldMapper<Sample>(typeof(Sample).GetProperty("Int"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(int)), "Int", 128, 1.0f);

            var sample = new Sample { Long = 1234L };
            var document = new Document();
            mapper.CopyToDocument(sample, document);

            var field = document.GetFieldable("Int");
            Assert.That(field.TokenStreamValue.ToString(), Is.EqualTo("(numeric,valSize=32,precisionStep=128)"));
        }
开发者ID:chriseldredge,项目名称:Lucene.Net.Linq,代码行数:11,代码来源:NumericReflectionFieldMapperTests.cs

示例7: StoreLong

        public void StoreLong()
        {
            mapper = new NumericReflectionFieldMapper<Sample>(typeof(Sample).GetProperty("Long"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(long)), "Long", NumericUtils.PRECISION_STEP_DEFAULT, 1.0f);

            var sample = new Sample { Long = 1234L };
            var document = new Document();
            mapper.CopyToDocument(sample, document);

            var field = document.GetFieldable("Long");
            Assert.That(field.TokenStreamValue.ToString(), Is.EqualTo("(numeric,valSize=64,precisionStep=4)"));
        }
开发者ID:chriseldredge,项目名称:Lucene.Net.Linq,代码行数:11,代码来源:NumericReflectionFieldMapperTests.cs

示例8: ThenIWantItToBeIndexedWithPrecisionStep

		public void ThenIWantItToBeIndexedWithPrecisionStep()
		{
			// Arrange
			var document = new Document();
			var input = DateTime.UtcNow;

			// Act
			document.Add(input).Indexed().WithPrecisionStep(8).As("Foo");

			// Assert
			var field = document.GetFieldable("Foo");
			Assert.True(field.IsIndexed);
		}
开发者ID:ChristopherHaws,项目名称:Lucene.Net.FluentApi,代码行数:13,代码来源:WhenIAddADateTimeField.cs

示例9: ThenIWantItToBeIndexed

		public void ThenIWantItToBeIndexed()
		{
			// Arrange
			var document = new Document();
			var input = 5f;

			// Act
			document.Add(input).Indexed().As("Foo");

			// Assert
			var field = document.GetFieldable("Foo");
			Assert.True(field.IsIndexed);
		}
开发者ID:ChristopherHaws,项目名称:Lucene.Net.FluentApi,代码行数:13,代码来源:WhenIAddASingleField.cs

示例10: ThenIWantItToBeIndexedWithBoost

		public void ThenIWantItToBeIndexedWithBoost()
		{
			// Arrange
			var document = new Document();
			var input = DateTime.UtcNow;
			var boost = 2.0f;

			// Act
			document.Add(input).Indexed().BoostBy(boost).As("Foo");

			// Assert
			var field = document.GetFieldable("Foo");
			Assert.True(field.IsIndexed);
			Assert.Equal(boost, field.Boost);
		}
开发者ID:ChristopherHaws,项目名称:Lucene.Net.FluentApi,代码行数:15,代码来源:WhenIAddADateTimeField.cs

示例11: ThenIWantItToBeIndexedWithPrecisionStepWithBoost

		public void ThenIWantItToBeIndexedWithPrecisionStepWithBoost()
		{
			// Arrange
			var document = new Document();
			var input = Int32.MaxValue;
			var boost = 2.0f;

			// Act
			document.Add(input).Indexed().WithPrecisionStep(8).BoostBy(boost).As("Foo");

			// Assert
			var field = document.GetFieldable("Foo");
			Assert.True(field.IsIndexed);
			Assert.Equal(boost, field.Boost);
		}
开发者ID:ChristopherHaws,项目名称:Lucene.Net.FluentApi,代码行数:15,代码来源:WhenIAddAnInt32Field.cs

示例12: OnIndexEntryCreated

			public override void OnIndexEntryCreated(string entryKey, Document document)
			{
				var resultDocId = document.GetField(setupDoc.DocumentKey);
				if (resultDocId == null)
				{
					log.Warn("Could not find document id property '{0}' in '{1}' for index '{2}'", setupDoc.DocumentKey, entryKey, index);
					return;
				}

				var documentId = resultDocId.StringValue;

				itemsToRemove.Remove(documentId);

				var resultDoc = database.Get(documentId, null);
				if (resultDoc == null)
				{
					log.Warn("Could not find a document with the id '{0}' for index '{1}'", documentId, index);
					return;
				}

				var entityName = resultDoc.Metadata.Value<string>(Constants.RavenEntityName);
				if(entityName != null && viewGenerator.ForEntityNames.Contains(entityName))
				{
					log.Warn(
						"Rejected update for a potentially recursive update on document '{0}' because the index '{1}' includes documents with entity name of '{2}'",
						documentId, index, entityName);
					return;
				}
				if(viewGenerator.ForEntityNames.Count == 0)
				{
					log.Warn(
						"Rejected update for a potentially recursive update on document '{0}' because the index '{1}' includes all documents",
						documentId, index);
					return;
				}

				var changesMade = false;
				foreach (var mapping in setupDoc.FieldNameMappings)
				{
					var field = 
						document.GetFieldable(mapping.Key + "_Range") ??
						document.GetFieldable(mapping.Key);
					if (field == null)
						continue;
					var numericField = field as NumericField;
					if (numericField != null)
					{
						resultDoc.DataAsJson[mapping.Value] = new RavenJValue(numericField.NumericValue);
					}
					else
					{
						resultDoc.DataAsJson[mapping.Value] = field.StringValue;
					}
					changesMade = true;
				}
				if (changesMade)
					database.Put(documentId, resultDoc.Etag, resultDoc.DataAsJson, resultDoc.Metadata, null);
			}
开发者ID:arelee,项目名称:ravendb,代码行数:58,代码来源:IndexedPropertiesTrigger.cs

示例13: OnIndexEntryCreated

            public override void OnIndexEntryCreated(string indexName, string entryKey, Document document)
            {
                using (var cmd = Connection.CreateCommand())
                {
                    cmd.Transaction = tx;
                    var pkParam = cmd.CreateParameter();
                    pkParam.ParameterName = GetParameterName("entryKey");
                    pkParam.Value = entryKey;
                    cmd.Parameters.Add(pkParam);

                    var sb = new StringBuilder("INSERT INTO ")
                        .Append(destination.TableName)
                        .Append(" (")
                        .Append(destination.PrimaryKeyColumnName)
                        .Append(", ");

                    foreach (var mapping in destination.ColumnsMapping)
                    {
                        sb.Append(mapping.Value).Append(", ");
                    }
                    sb.Length = sb.Length - 2;

                    sb.Append(") \r\nVALUES (")
                        .Append(pkParam.ParameterName)
                        .Append(", ");

                    foreach (var mapping in destination.ColumnsMapping)
                    {
                        var parameter = cmd.CreateParameter();
                        parameter.ParameterName = GetParameterName(mapping.Key);
                        var field = document.GetFieldable(mapping.Key);
                        if (field == null)
                            parameter.Value = DBNull.Value;
                        else if(field is NumericField)
                        {
                            var numField = (NumericField) field;
                            parameter.Value = numField.GetNumericValue();
                        }
                        else
                            parameter.Value = field.StringValue();
                        cmd.Parameters.Add(parameter);
                        sb.Append(parameter.ParameterName).Append(", ");
                    }
                    sb.Length = sb.Length - 2;
                    sb.Append(")");
                    cmd.CommandText = sb.ToString();
                    cmd.ExecuteNonQuery();
                }
            }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:49,代码来源:IndexReplicationIndexUpdateTrigger.cs

示例14: OnIndexEntryCreated

			public override void OnIndexEntryCreated(string entryKey, Document document)
			{
				using (var cmd = Connection.CreateCommand())
				{
					cmd.Transaction = tx;
					var pkParam = cmd.CreateParameter();
					pkParam.ParameterName = GetParameterName("entryKey");
					pkParam.Value = entryKey;
					cmd.Parameters.Add(pkParam);

					var sb = new StringBuilder("INSERT INTO ")
						.Append(destination.TableName)
						.Append(" (")
						.Append(destination.PrimaryKeyColumnName)
						.Append(", ");

					foreach (var mapping in destination.ColumnsMapping)
					{
						sb.Append(mapping.Value).Append(", ");
					}
					sb.Length = sb.Length - 2;

					sb.Append(") \r\nVALUES (")
						.Append(pkParam.ParameterName)
						.Append(", ");

					foreach (var mapping in destination.ColumnsMapping)
					{
						var parameter = cmd.CreateParameter();
						parameter.ParameterName = GetParameterName(mapping.Key);
						var field = document.GetFieldable(mapping.Key);

						var numericfield = document.GetFieldable(String.Concat(mapping.Key, "_Range"));
						if (numericfield != null)
							field = numericfield;

						if (field == null || field.StringValue == Constants.NullValue)
							parameter.Value = DBNull.Value;
						else if (field is NumericField)
						{
							var numField = (NumericField)field;
							parameter.Value = numField.NumericValue;
						}
						else
						{
							var stringValue = field.StringValue;
							if (datePattern.IsMatch(stringValue))
							{
								try
								{
									parameter.Value = DateTools.StringToDate(stringValue);
								}
								catch
								{
									parameter.Value = stringValue;
								}
							}
							else
							{
								DateTime time;
								if (DateTime.TryParseExact(stringValue, Default.DateTimeFormatsToRead, CultureInfo.InvariantCulture,
														   DateTimeStyles.None, out time))
								{
									parameter.Value = time;
								}
								else
								{
									parameter.Value = stringValue;
								}
							}
						}

						cmd.Parameters.Add(parameter);
						sb.Append(parameter.ParameterName).Append(", ");
					}
					sb.Length = sb.Length - 2;
					sb.Append(")");
					cmd.CommandText = sb.ToString();
					cmd.ExecuteNonQuery();
				}
			}
开发者ID:shiranGinige,项目名称:ravendb,代码行数:81,代码来源:IndexReplicationIndexUpdateTrigger.cs

示例15: GetStringFromField

			private string GetStringFromField(Document document, string propertyName)
			{
				var fieldable    = document.GetFieldable(propertyName);
				var numericfield = document.GetFieldable(String.Concat(propertyName, "_Range"));

				if (numericfield != null)
					return String.Format(CultureInfo.InvariantCulture, "{0}", ((NumericField) numericfield).GetNumericValue());

				if (fieldable == null)
					return String.Empty;

				var stringValue = fieldable.StringValue();

				if (datePattern.IsMatch(stringValue))
				{
					try
					{
						return DateTools.StringToDate(stringValue).ToString("u");
					}
					catch { }
				}

				return stringValue;
			}
开发者ID:pacoweb,项目名称:ravendb,代码行数:24,代码来源:IndexReplicationToRedisIndexUpdateTrigger.cs


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