简体   繁体   中英

Elasticsearch Nest, parent/child relationship

can you help me out to define a parent/child relationship using NESTclient for elasticsearch? my code looks like this:

[ElasticType(Name = "type_properties", DateDetection = true,.....)]
public class Properties{....}

[ElasticType(Name = "type_sales", DateDetection = true, , ParentType = "type_properties")]
public class SalesHistory{....}

I defined the parentType, but I don't see this sales documents related to a parent property.

{
  "_index": "testparentchild",
  "_type": "type_sales",
  "_id": "dVd1tUJ0SNyoiSer7sNA",
  "_version": 1,
  "_score": 1,
  "_source": {
    "salesRecId": 179504762,
    "salesPrice": 150000,
    "salesDate": "2003-04-07T00:00:00",
  }
}

The attribute based mapping is deprecated since all the possible mapping possibilities cannot be expressed that way.

See https://github.com/elasticsearch/elasticsearch-net/blob/master/src/Tests/Nest.Tests.Unit/Core/Map/FluentMappingFullExampleTests.cs

How to properly apply a mapping for your type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM