I have the following docs:export class CustomerServiceResultType{ id: string; body:{customerRelation: string};}export class CustomerType{ id: string; body:{name: string};}I want CustomerServiceResultType to have a relation to CustomerType with the field: customerRelation.this is my mapping:await this.elasticsearchService.indices.putMapping({ "index": "db", "type": "CustomerServiceResultType", "body" : { "properties": { "customerRelation": { "type": "join", "relations": { "CustomerServiceResultType": "CustomerType" } } } }});This is the error I get:[Nest] 421512 - 11/21/2020, 6:40:42 PM [ExceptionsHandler] illegal_argument_exception +96414msResponseError: illegal_argument_exceptionThere are no details about this error...Thanks 解决方案 There's nothing wrong with your request per-se -- I think it just requires one extra option: include_type_name: true.It's undefined by default in nodejs but is required in ES 7.x on the server side. More reasoning behind this is here.So this should do the trick:await client.indices.putMapping({ include_type_name: true, index: "db", type: "CustomerServiceResultType", body : { properties: { customerRelation: { type: "join", relations: { CustomerServiceResultType: "CustomerType" } } } }});Typed indexes will be removed in 8.x so the best approach would actually be:await client.indices.putMapping({ index: "db", body : { properties: { customerRelation: { type: "join", relations: { CustomerServiceResultType: "CustomerType" } } } }});BTW: your typescript types don't really play a role here because ES is a JSON-only interface and while there's the deprecated type aspect to ES, the two concepts are very distant. 这篇关于Elasticsearch创建联接字段(Node.js)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!