我是Elasticsearch和Nest中的新成员,并且在问题中被阻止。我想要做的是创建一个索引并索引带有嵌套字段的文档。Elasticsearch Nest 2.x索引嵌套对象
[ElasticsearchType]
public class TestType
{
[Nest.String(Store = true, Index = FieldIndexOption.Analyzed)]
public string Text { get; set; }
[Nested(IncludeInAll = true)]
public List<NestedTestType> Nests { get; set; } = new List<NestedTestType>();
public string Id { get; set; }
}
[ElasticsearchType]
public class NestedTestType
{
[Nest.String(Store = true, Index = FieldIndexOption.Analyzed)]
public string Value { get; set; }
[Nest.String(Store = false)]
public string NotStoredValue { get; set; }
}
和在函数是
var connectionPool = new Elasticsearch.Net.SniffingConnectionPool(poolUris);
var settings = new ConnectionSettings(connectionPool);
client = new ElasticClient(settings);
string testIndexName = "test";
var createIndeReponse = client.CreateIndex(testIndexName);
var mappingResponse = client.Map<TestType>(m => m.Index(testIndexName).AutoMap());
mappingResponse = client.Map<NestedTestType>(m => m.Index(testIndexName).AutoMap());
TestType testData = new TestType() { Text = "Hello world" };
testData.Nests.Add(new NestedTestType() { Value = "In the list", NotStoredValue = "Not stored"});
IndexRequest<TestType> indexRequest = new IndexRequest<TestType>(testIndexName, "test_type");
indexRequest.Document = testData;
IIndexResponse iir = client.Index(indexRequest);
然而,在最后一行的IIR包含错误“对象映射[巢]不能改变从嵌套到非嵌套”
我的问题是:
什么是做索引的正确方法? 我在哪里可以找到有助于我进一步研究的文档?
您可能感兴趣的索引映射(http:// localhost:9200/test/_mapping)? – Rob