Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch 在ElasticSearch(Nest)中,Can';如果未配置父字段,则不指定父字段_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Nest - Fatal编程技术网 elasticsearch 在ElasticSearch(Nest)中,Can';如果未配置父字段,则不指定父字段,elasticsearch,nest,elasticsearch,Nest" /> elasticsearch 在ElasticSearch(Nest)中,Can';如果未配置父字段,则不指定父字段,elasticsearch,nest,elasticsearch,Nest" />

elasticsearch 在ElasticSearch(Nest)中,Can';如果未配置父字段,则不指定父字段

elasticsearch 在ElasticSearch(Nest)中,Can';如果未配置父字段,则不指定父字段,elasticsearch,nest,elasticsearch,Nest,我正在使用Nest客户端与ElasticSearch通信 当我尝试索引子类型时,标题中出现了错误。我已经在父类型:[ElasticType(Name=“item”,IdProperty=“id”)]上设置了此属性。这应该告诉弹性类型关于id字段 下面是nest使用错误信息进行的查询 {StatusCode: 400, Method: PUT, Url: http://localhost:9200/itemindex/inventory/15894?routing=15894&

我正在使用Nest客户端与ElasticSearch通信

当我尝试索引子类型时,标题中出现了错误。我已经在父类型:[ElasticType(Name=“item”,IdProperty=“id”)]上设置了此属性。这应该告诉弹性类型关于id字段

下面是nest使用错误信息进行的查询

{StatusCode: 400, 
    Method: PUT, 
    Url: http://localhost:9200/itemindex/inventory/15894?routing=15894&parent=15894, 
    Request: {
  "itemId": 15894,
  "inventories": [
    {
      "storeId": 20693,
      "inventoryCount": 40
    }
]
}

Response: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Can't specify parent if no parent field has been configured"}],"type":"illegal_argument_exception","reason":"Can't specify parent if no parent field has been configured"},"status":400}}
当我用sense直接使用这个查询时。它正在成功插入和更新数据。但当我试着用鸟巢的时候就不行了

请建议?感谢您的帮助。先谢谢你


有人能解释一下这个错误的原因吗?

我不知道您的索引映射,但看起来您在为子文档定义映射时忘记了指定父文档

这就是使用NEST 2.0.0-alpha1实现此功能的方法

public class Parent
{
    public int Id { get; set; }
    public string Name { get; set; }
}

public class Child
{
    public int Id { get; set; }
    public string Name { get; set; }
}

var response = client.CreateIndex(indexName, d => d
    .Mappings(map => map
        .Map<Parent>(m => m.AutoMap())
        .Map<Child>(m => m.AutoMap().Parent<Parent>())));   
公共类父类
{
公共int Id{get;set;}
公共字符串名称{get;set;}
}
公营儿童
{
公共int Id{get;set;}
公共字符串名称{get;set;}
}
var response=client.CreateIndex(indexName,d=>d
.Mappings(map=>map
.Map(m=>m.AutoMap())
.Map(m=>m.AutoMap().Parent());

希望有帮助。

我已经添加了这个,但不知道怎么回事。。。。SearchClient.Map(x=>x.MapFromAttributes().SetParent());NEST 1.x与ES 2.x不兼容,因此这可能是这里的问题。NEST的最新版本是1.7,应该与elasticsearch 2.x兼容。我说得对。NEST的最新版本是2.0.0-alpha1。1.7与ES 2.x.Any解决方案不兼容..?问题是由于Nest 1.7与2.0.x ElasticSearch不兼容。@Rob在评论中提到了这一点。