本文整理汇总了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);
}
示例2: ToString
public override string ToString()
{
var elasticsearchCrudJsonWriter = new ElasticsearchCrudJsonWriter();
WriteJson(elasticsearchCrudJsonWriter);
return elasticsearchCrudJsonWriter.GetJsonString();
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}