elasticsearch 如何设置IndexOption=docs
我需要用NEST Elastic Search.NET客户端获得下面的结果elasticsearch 如何设置IndexOption=docs,elasticsearch,nest,elasticsearch,Nest,我需要用NEST Elastic Search.NET客户端获得下面的结果 "detailVal": { "name": "detailVal", "type": "multi_field", "fields": { "detailVal": { "type": "string" }, "untouched": { // <== FOCUS 2
"detailVal": {
"name": "detailVal",
"type": "multi_field",
"fields": {
"detailVal": {
"type": "string"
},
"untouched": { // <== FOCUS 2
"type": "string",
"index": "not_analyzed",
"omit_norms": true,
"include_in_all": false,
"index_options": "docs" // <== FOCUS 1
}
}
}
这让我很生气
"detailVal": {
"name": "detailVal",
"type": "multi_field",
"fields": {
"detailVal": {
"type": "string",
"index": "not_analyzed",
"omit_norms": true,
"include_in_all": false
},
"sort": { // <== FOCUS 2
"type": "string",
"index": "not_analyzed"
}
}
}
那么,你知道怎么做吗
添加索引\u选项:我找到的文档IndexOptions.docs,但它作为属性无效
将排序更改为未触及
基于属性的映射仅能让您了解到这一点。如果只需要更改名称和设置简单属性,这就足够了 建议使用client.MapFluent 看 有关如何设置索引_选项的示例 第208行: 查看如何创建自己的多字段映射 您甚至可以结合使用这两种方法:
client.MapFluent<MyType>(m=>m
.MapFromAttributes()
//Map what you can't with attributes here
);
client.Map和client.MapFromAttributes很可能在某个时候被删除。@martjin laaman谢谢!我已经知道流畅的语法,但我不想仅仅因为这两个问题就放弃属性方法。再次感谢您的时间!这两种方法都可以,在MapFluent中调用MapFromAttributes,然后只映射其他方法无法映射的内容。
client.MapFluent<MyType>(m=>m
.MapFromAttributes()
//Map what you can't with attributes here
);