elasticsearch ElasticSearch-父子关系,elasticsearch,nest,elasticsearch,Nest" /> elasticsearch ElasticSearch-父子关系,elasticsearch,nest,elasticsearch,Nest" />

elasticsearch ElasticSearch-父子关系

elasticsearch ElasticSearch-父子关系,elasticsearch,nest,elasticsearch,Nest,我正在尝试使用NEST client for C#创建父子关系。这是我的密码。我使用的是elasticsearch 1.1.1,这段代码似乎将testp1对象添加到testparent索引中,但没有将任何对象添加到testchild索引中。如果我不使用索引参数传递父级,它似乎可以正常工作。任何有关这方面的帮助都将不胜感激 private static void LoadTestData() { var esClient = CreateNESTConnection(); esCl

我正在尝试使用NEST client for C#创建父子关系。这是我的密码。我使用的是elasticsearch 1.1.1,这段代码似乎将testp1对象添加到testparent索引中,但没有将任何对象添加到testchild索引中。如果我不使用索引参数传递父级,它似乎可以正常工作。任何有关这方面的帮助都将不胜感激

private static void LoadTestData()
{
    var esClient = CreateNESTConnection();
    esClient.MapFluent<testparent>(x => x
        .IndexName("testdb")
        .TypeName("testparent")
        .IdField(y => y.SetPath("Id"))
        .Properties(cprops => cprops
            .String(a => a.Name("id"))
            .Number(a => a.Name("parentid").Type(NumberType.@long))
            .Number(a => a.Name("prop1").Type(NumberType.@long))
            .Number(a => a.Name("prop2").Type(NumberType.@long))
            .Boolean(a => a.Name("checkflag"))
    ));

    esClient.MapFluent<testchild>(x => x
        .IndexName("testdb")
        .TypeName("testchild")
        .SetParent("testparent")
        .Properties(cprops => cprops
            .Number(a => a.Name("dockey").Type(NumberType.@long))
            .Number(a => a.Name("docvalue").Type(NumberType.@float))
    ));

    testparent testp1 = new testparent();
    testp1.checkflag = true;
    testp1.id = "7";
    testp1.parentid = 77;
    testp1.prop1 = 1;
    testp1.prop2 = 2;
    testchild testc1 = new testchild();
    testc1.dockey = 100;
    testc1.docvalue = 111;

    testchild testc2 = new testchild();
    testc2.dockey = 100;
    testc2.docvalue = 111;

    esClient.Index(testp1, "testdb");
    IndexParameters parameters = new IndexParameters();
    parameters.Parent = "7";
    var t = esClient.Index(testc1, "testdb", parameters);
    Console.WriteLine(t.OK);
    t = esClient.Index(testc2, "testdb", parameters);
    Console.WriteLine(t.OK);
}
private static void LoadTestData()
{
var esClient=CreateNESTConnection();
esClient.MapFluent(x=>x
.IndexName(“testdb”)
.TypeName(“testparent”)
.IdField(y=>y.SetPath(“Id”))
.Properties(cprops=>cprops
.String(a=>a.Name(“id”))
.Number(a=>a.Name(“parentid”).Type(NumberType.@long))
.Number(a=>a.Name(“prop1”).Type(NumberType.@long))
.Number(a=>a.Name(“prop2”).Type(NumberType.@long))
.Boolean(a=>a.Name(“检查标志”))
));
esClient.MapFluent(x=>x
.IndexName(“testdb”)
.TypeName(“testchild”)
.SetParent(“testparent”)
.Properties(cprops=>cprops
.Number(a=>a.Name(“dockey”).Type(NumberType.@long))
.Number(a=>a.Name(“docvalue”).Type(NumberType@float))
));
testparent testp1=新的testparent();
testp1.checkflag=true;
testp1.id=“7”;
testp1.parentid=77;
testp1.prop1=1;
testp1.prop2=2;
testchild testc1=新的testchild();
testc1.dockey=100;
testc1.docvalue=111;
testchild testc2=新的testchild();
testc2.docey=100;
testc2.docvalue=111;
客户索引(testp1,“testdb”);
IndexParameters参数=新的IndexParameters();
parameters.Parent=“7”;
var t=客户索引(testc1,“testdb”,参数);
控制台写入线(t.OK);
t=esClient.Index(testc2,“testdb”,参数);
控制台写入线(t.OK);
}

您有什么解决方案吗?