[英]How to get fields from Elasticsearch with Node.js client
I am trying to get fields from localhost:9200/monIndex/monType/_mapping
我正在尝试从localhost:9200/monIndex/monType/_mapping
获取字段localhost:9200/monIndex/monType/_mapping
I am using the Elasticsearch API: 我正在使用Elasticsearch API:
client.indices.getMapping({
index: 'monIndex',
type:'monType',
}).then(function (response) {
callback(response);
});
The response returned is the object containing the _mapping
from ES, but I only need to retrieve fields. 返回的响应是包含来自ES的_mapping
的对象,但是我只需要检索字段。
I have a nested mapping. 我有一个嵌套的映射。
Correct syntax is : 正确的语法是:
<host>:<port>/<index|indices>/_mapping/field/<field|fields>
For eg: 例如:
localhost:9200/monIndex/_mapping/field/monType
documentation : https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html 文档: https : //www.elastic.co/guide/zh-CN/elasticsearch/reference/current/indices-get-field-mapping.html
You need to use indices.getFieldMapping
instead of getMapping
: 您需要使用indices.getFieldMapping
代替getMapping
:
client.indices.getFieldMapping({
index: 'monIndex',
type:'monType',
fields: 'field1,field2,field3'
}).then(function (response) {
callback(response);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.