zoukankan      html  css  js  c++  java
  • Elasticsearch——禁止Body中的index覆盖Url中的index参数

    本篇继续一下Elasticsearch日常使用的技巧翻译。

    在Elasticsearch有很多的api支持在body中指定_index等信息,比如mget或者msearch以及bulk。

    默认的情况下,body中的index会覆盖掉url中的index参数。比如:

    $ curl localhost:9200/test/_mget?pretty -d '{"docs":[{"_index":"test1","_id":1},{"_index":"test2","_id":2}]}'
    {
      "docs" : [ {
        "_index" : "test1",
        "_type" : "tet",
        "_id" : "1",
        "_version" : 2,
        "found" : true,
        "_source":{"name":"1"}
      }, {
        "_index" : "test2",
        "_type" : null,
        "_id" : "2",
        "found" : false
      } ]
    }
    

    虽说在url中指定了index为test,但是执行到每个文档时,仍然会按照body里面的内容为准。

    此时可以通过设置参数rest.action.multi.allow_explicit_indexfalse来关闭覆盖功能。

    这个设置会对所有的节点起作用,设置方法如下:

    config/elasticsearch.yml中添加:

    rest.action.multi.allow_explicit_index: false
    

    然后重启Elasticsearch,再次执行就会发现,服务器已经提示拒绝。

    $ curl localhost:9200/test/_mget?pretty -d '{"docs":[{"_index":"test1","_id":1},{"_index":"test2","_id":2}]}'
    {
      "error" : "ElasticsearchIllegalArgumentException[explicit index in multi get is not allowed]",
      "status" : 400
    }
    
  • 相关阅读:
    mui---子页面主动调用父页面的方法
    宝塔使用FTP的问题
    css---颜色过渡渐变
    mui---开发直播APP
    mui---计算缓存大小及清除缓存
    mui---自定义页面打开的方向
    mui---取消掉默认加载框
    mui+回复弹出软键盘
    还不错的MUI技术文档
    mui---父页面跳子页面刷新子页面
  • 原文地址:https://www.cnblogs.com/xing901022/p/5308950.html
Copyright © 2011-2022 走看看