node.js - 使用nodejs lib在elasticsearch上执行原始查询

标签 node.js elasticsearch kibana

我可以使用 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/

相关文章:

Kibana 过滤器正则表达式 'string starts with' 不起作用

node.js - 不要让部署取消文件上传

javascript - 解决node-mysql初始化错误?

elasticsearch - 从 Nest 客户端 Elasticsearch 2.3 序列化查询

elasticsearch - Elasticsearch:创建索引时设置的总字段数限制

elasticsearch - 使用为其他索引模式(相同数据)创建的Visualize Kibana?

elasticsearch - EFK与Searchguard

node.js - Mongoose聚合错误: Arguments must be aggregate pipeline operators

javascript - 在 javascript/nodejs 中搜索并替换所有内容

elasticsearch - Elasticsearch 中的查询字符串与通配符之间有什么区别