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


C# ElasticsearchCrudJsonWriter.GetJsonString方法代码示例

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


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

示例1: SerializeAnalyzerWithAsciifoldingFilter

        public void SerializeAnalyzerWithAsciifoldingFilter()
        {
            const string targetJson =
                "\"analysis\":{\"filter\":{\"my_ascii_folding\":{\"type\":\"asciifolding\",\"preserve_original\":true}},\"analyzer\":{\"default\":{\"type\":\"custom\",\"tokenizer\":\"standard\",\"filter\":[\"standard\",\"my_ascii_folding\"]}}}";

            var analysis = new Analysis
            {
                Analyzer =
                {
                    Analyzers = new List<AnalyzerBase>
                    {
                        new CustomAnalyzer("default")
                        {
                            Tokenizer = DefaultTokenizers.Standard,
                            Filter = new List<string> {"standard", "my_ascii_folding"}
                        }
                    }
                },
                Filters =
                {
                    CustomFilters = new List<AnalysisFilterBase> {new AsciifoldingTokenFilter("my_ascii_folding") {PreserveOriginal = true}}
                }
            };

            var jsonWriter = new ElasticsearchCrudJsonWriter();
            analysis.WriteJson(jsonWriter);
            var result = jsonWriter.GetJsonString();
            Console.WriteLine(result);
            Assert.AreEqual(targetJson, result);
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:30,代码来源:AnalysisTests.cs

示例2: ToString

 public override string ToString()
 {
     var elasticsearchCrudJsonWriter = new ElasticsearchCrudJsonWriter();
     WriteJson(elasticsearchCrudJsonWriter);
     return elasticsearchCrudJsonWriter.GetJsonString();
 }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:6,代码来源:AliasParameters.cs

示例3: CreateIndexSettingsForDocument

		public void CreateIndexSettingsForDocument(string index, IndexSettings indexSettings, IndexAliases indexAliases, IndexWarmers indexWarmers)
		{
			if (_processedItems.Contains("_index" + index))
			{
				return;
			}
			_processedItems.Add("_index" + index);
			var elasticsearchCrudJsonWriter = new ElasticsearchCrudJsonWriter();
			elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();
			CreateIndexSettings(elasticsearchCrudJsonWriter, indexSettings);
			indexAliases.WriteJson(elasticsearchCrudJsonWriter);
			indexWarmers.WriteJson(elasticsearchCrudJsonWriter);
			elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();

			CreateIndexCommand(elasticsearchCrudJsonWriter.GetJsonString(), index);
		}
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:16,代码来源:IndexMappings.cs

示例4: CreatePropertyMappingForChildDocument

		/// <summary>
		/// Create a new mapping for the child type in the parent document index
		/// </summary>
		/// <param name="entityInfo"></param>
		/// <param name="elasticsearchMapping"></param>
		/// <param name="item"></param>
		/// <param name="mappingDefinition">definition for the type mappings</param>
		private void CreatePropertyMappingForChildDocument(EntityContextInfo entityInfo, ElasticsearchMapping elasticsearchMapping, EntityContextInfo item, MappingDefinition mappingDefinition)
		{
			var childMapping =
				_elasticsearchSerializerConfiguration.ElasticsearchMappingResolver.GetElasticSearchMapping(item.EntityType);

			var parentMapping =
				_elasticsearchSerializerConfiguration.ElasticsearchMappingResolver.GetElasticSearchMapping(item.ParentEntityType);

			var childType = childMapping.GetDocumentType(item.EntityType);
			var parentType = parentMapping.GetDocumentType(item.ParentEntityType);

			var processedId = childType + "_" + parentType;
			if (_processedItems.Contains(childType))
			{
				var test = CommandTypes.Find(t => t.StartsWith(childType));
				if (test != processedId)
				{
					throw new ElasticsearchCrudException("InitMappings: Not supported, child documents can only have one parent");
				}
				return;
			}
			_processedItems.Add(childType);
			CommandTypes.Add(processedId);

			var elasticsearchCrudJsonWriter = new ElasticsearchCrudJsonWriter();
			elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();

			elasticsearchCrudJsonWriter.JsonWriter.WritePropertyName(childType);
			elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();

			mappingDefinition.Source.WriteJson(elasticsearchCrudJsonWriter);
			mappingDefinition.All.WriteJson(elasticsearchCrudJsonWriter);
			mappingDefinition.Analyzer.WriteJson(elasticsearchCrudJsonWriter);

			CreateParentMappingForDocument(
				elasticsearchCrudJsonWriter,
				elasticsearchMapping.GetDocumentType(item.ParentEntityType));

			if (item.RoutingDefinition.RoutingId != null && _elasticsearchSerializerConfiguration.UserDefinedRouting)
			{
				CreateForceRoutingMappingForDocument(elasticsearchCrudJsonWriter);
			}

			ProccessPropertyMappingsWithoutTypeName(elasticsearchCrudJsonWriter, item, childMapping);
			elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();
			elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();
			CreateMappingCommandForTypeWithExistingIndex(elasticsearchCrudJsonWriter.GetJsonString(), elasticsearchMapping.GetIndexForType(entityInfo.EntityType), childMapping.GetDocumentType(item.EntityType));
		}
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:55,代码来源:IndexMappings.cs

示例5: CreatePropertyMappingForEntityForParentDocument

		/// <summary>
		/// Create a new index for the parent document
		/// </summary>
		/// <param name="entityInfo"></param>
		/// <param name="elasticsearchMapping"></param>
		/// <param name="mappingDefinition">mapping definitions for the index type</param>
		private void CreatePropertyMappingForEntityForParentDocument(EntityContextInfo entityInfo, ElasticsearchMapping elasticsearchMapping, MappingDefinition mappingDefinition)
		{
			var itemType = elasticsearchMapping.GetDocumentType(entityInfo.EntityType);
			if (_processedItems.Contains("_mapping" +itemType))
			{
				return;
			}
			_processedItems.Add("_mapping" +itemType);

			var elasticsearchCrudJsonWriter = new ElasticsearchCrudJsonWriter();
			elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();
			elasticsearchCrudJsonWriter.JsonWriter.WritePropertyName(itemType);
			elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();

			mappingDefinition.Source.WriteJson(elasticsearchCrudJsonWriter);
			mappingDefinition.All.WriteJson(elasticsearchCrudJsonWriter);
			mappingDefinition.Analyzer.WriteJson(elasticsearchCrudJsonWriter);

			if (entityInfo.RoutingDefinition.RoutingId != null && _elasticsearchSerializerConfiguration.UserDefinedRouting)
			{
				CreateForceRoutingMappingForDocument(elasticsearchCrudJsonWriter);
			}

			if (entityInfo.RoutingDefinition.ParentId != null)
			{
				CreateParentMappingForDocument(
				elasticsearchCrudJsonWriter,
				elasticsearchMapping.GetDocumentType(entityInfo.ParentEntityType));
			}

			ProccessPropertyMappingsWithoutTypeName(elasticsearchCrudJsonWriter, entityInfo, elasticsearchMapping);

			elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();
			elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();

			CreateMappingCommandForTypeWithExistingIndex(elasticsearchCrudJsonWriter.GetJsonString(), mappingDefinition.Index, itemType);
		
		}
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:44,代码来源:IndexMappings.cs

示例6: UpdateSettings

		public void UpdateSettings(string index, IndexUpdateSettings indexUpdateSettings)
		{
			var elasticsearchCrudJsonWriter = new ElasticsearchCrudJsonWriter();
			elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();
			elasticsearchCrudJsonWriter.JsonWriter.WritePropertyName("index");
			elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject();
			indexUpdateSettings.WriteJson(elasticsearchCrudJsonWriter);
			elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();
			elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject();

			SettingsCommand(elasticsearchCrudJsonWriter.GetJsonString(), index);
		}
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:12,代码来源:IndexMappings.cs

示例7: SerializeAnalyzerWithEdgeNGramTokenizer

        public void SerializeAnalyzerWithEdgeNGramTokenizer()
        {
            const string targetJson =
                "\"analysis\":{\"tokenizer\":{\"my_edgengram_tokenizer\":{\"type\":\"edgeNGram\",\"min_gram\":2,\"max_gram\":4,\"token_chars\":[\"digit\",\"letter\"]}},\"analyzer\":{\"default\":{\"type\":\"custom\",\"tokenizer\":\"my_edgengram_tokenizer\"}}}";

            var analysis = new Analysis
            {
                Analyzer =
                {
                    Analyzers = new List<AnalyzerBase>
                    {
                        new CustomAnalyzer("default")
                        {
                            Tokenizer = "my_edgengram_tokenizer"
                        }
                    }
                },
                Tokenizers =
                {
                    CustomTokenizers = new List<AnalysisTokenizerBase>
                    {
                        new EdgeNGramTokenizer("my_edgengram_tokenizer")
                        {
                            MaxGram = 4,
                            MinGram = 2,
                            TokenChars = new List<TokenChar> {TokenChar.digit, TokenChar.letter}
                        }
                    }
                }
            };

            var jsonWriter = new ElasticsearchCrudJsonWriter();
            analysis.WriteJson(jsonWriter);
            var result = jsonWriter.GetJsonString();
            Console.WriteLine(result);
            Assert.AreEqual(targetJson, result);
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:37,代码来源:AnalysisTests.cs

示例8: SerializeBlocksAnalyzer

        public void SerializeBlocksAnalyzer()
        {
            const string targetJson = "\"analysis\":{\"analyzer\":{\"blocks_analyzer\":{\"type\":\"custom\",\"tokenizer\":\"whitespace\",\"filter\":[\"lowercase\",\"blocks_filter\",\"shingle\"]}}}";
            var analysis = new Analysis
            {
                Analyzer =
                {
                    Analyzers = new List<AnalyzerBase>
                    {
                        new CustomAnalyzer("blocks_analyzer")
                        {
                            Tokenizer = DefaultTokenizers.Whitespace,
                            Filter = new List<string> {"lowercase", "blocks_filter", "shingle"}
                        },

                    }
                }
            };

            var jsonWriter = new ElasticsearchCrudJsonWriter();
            analysis.WriteJson(jsonWriter);
            var result = jsonWriter.GetJsonString();
            Console.WriteLine(result);
            Assert.AreEqual(targetJson,result);
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:25,代码来源:AnalysisTests.cs

示例9: SerializeAnalyzerWithStandardTokenizer

        public void SerializeAnalyzerWithStandardTokenizer()
        {
            const string targetJson =
                "\"analysis\":{\"tokenizer\":{\"bigger_limit_token_count\":{\"type\":\"standard\",\"max_token_length\":360}},\"analyzer\":{\"default\":{\"type\":\"custom\",\"tokenizer\":\"bigger_limit_token_count\"}}}";

            var analysis = new Analysis
            {
                Analyzer =
                {
                    Analyzers = new List<AnalyzerBase>
                    {
                        new CustomAnalyzer("default")
                        {
                            Tokenizer = "bigger_limit_token_count"
                        }
                    }
                },
                Tokenizers =
                {
                    CustomTokenizers = new List<AnalysisTokenizerBase>
                    {
                        new StandardTokenizer("bigger_limit_token_count") {MaxTokenLength = 360}
                    }
                }
            };

            var jsonWriter = new ElasticsearchCrudJsonWriter();
            analysis.WriteJson(jsonWriter);
            var result = jsonWriter.GetJsonString();
            Console.WriteLine(result);
            Assert.AreEqual(targetJson, result);
        }
开发者ID:jnus,项目名称:ElasticsearchCRUD,代码行数:32,代码来源:AnalysisTests.cs


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