代码之家  ›  专栏  ›  技术社区  ›  rap-2-h

使用nodejs lib对elasticsearch执行原始查询

  •  1
  • rap-2-h  · 技术社区  · 7 年前

    我可以用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一样。这可能吗?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Tarek Essam    7 年前

    索引.创建

    client.indices.create([params, [callback]])
    

    例子

    client.indices.create({
       index: "persons",
       body: {
           "settings" : {
           "number_of_shards" : 1
           },
           "mappings" : {
              "type1" : {
                "properties" : {
                "field1" : { "type" : "text" }
               }
            }
         }
       }
    })
    

    indices.create

    推荐文章