我可以使用 NodeJS Elastcsearch lib ( https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/quick-start.html ) 执行搜索。
有没有办法对索引执行原始查询?我可以执行这样的事情吗:
PUT index
{
"settings": {
"analysis": {
"normalizer": {
"my_normalizer": {
"type": "custom",
"char_filter": [],
"filter": ["lowercase", "asciifolding"]
}
}
}
},
"mappings": {
"_doc": {
"properties": {
"foo": {
"type": "keyword",
"normalizer": "my_normalizer"
}
}
}
}
}
...并以 JSON 形式获取结果,就像使用 Kibana 一样。这可能吗?
最佳答案
您可以使用indices.create
client.indices.create([params, [callback]])
示例
client.indices.create({
index: "persons",
body: {
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"properties" : {
"field1" : { "type" : "text" }
}
}
}
}
})
查看文档 indices.create
关于node.js - 使用nodejs lib在elasticsearch上执行原始查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52876763/