zoukankan      html  css  js  c++  java
  • elasticsearch wildcard查询大小写敏感问题解决

    先给以前的index加上别名,并且程序里面也修改一下查询index_execution改为查询index_execution_active

    curl -XPUT http://15.99.72.167:9200/index_execution/_alias/index_execution_active

    然后新建一个索引,如下所示,其中最关键的是新增了标红的部分的normalizer   这是taskcode和tasktitle这2个字段能够不区分大小写的关键


    curl -XDELETE http://15.99.72.167:9200/index_execution_20200414

    curl -XPUT http://15.99.72.167:9200/index_execution_20200414 -d '
    {

    "settings": {
    "index": {
    "number_of_shards": "5",
    "number_of_replicas": "0"
    },
    "analysis": {
    "normalizer": {
    "lowercase": {
    "type": "custom",
    "filter": [
    "lowercase"
    ]
    }
    }
    }
    }

    }
    '

    curl -XPUT http://15.99.72.167:9200/index_execution_20200414/_mapping/type_execution?pretty -d '{

    "properties": {
    "owner": {
    "type": "keyword"
    },
    "assignner": {
    "type": "text"
    },
    "completion": {
    "type": "double"
    },
    "pass": {
    "type": "text"
    },
    "taskcode": {
    "type": "keyword",
    "normalizer": "lowercase"
    },
    "tester": {
    "type": "keyword"
    },
    "refobs": {
    "type": "text"
    },
    "testsite": {
    "type": "integer"
    },
    "startdate": {
    "format": "yyyy/MM/dd",
    "type": "date"
    },
    "platform": {
    "type": "keyword"
    },
    "categoryb": {
    "type": "text"
    },
    "categoryc": {
    "type": "text"
    },
    "fail": {
    "type": "text"
    },
    "total": {
    "type": "text"
    },
    "enddate": {
    "format": "yyyy/MM/dd",
    "type": "date"
    },
    "na": {
    "type": "text"
    },
    "categorya": {
    "type": "text"
    },
    "tasktitle": {
    "type": "keyword",
    "normalizer": "lowercase"
    },
    "block": {
    "type": "text"
    },
    "id": {
    "type": "text",
    "fields": {
    "keyword": {
    "ignore_above": 256,
    "type": "keyword"
    }
    }
    },
    "newobs": {
    "type": "text"
    },
    "taskExecutionIntancelistViews": {
    "properties": {
    "completion": {
    "type": "float"
    },
    "fail": {
    "type": "long"
    },
    "instanceCode": {
    "type": "keyword"
    },
    "total": {
    "type": "long"
    },
    "na": {
    "type": "long"
    },
    "instanceName": {
    "type": "keyword"
    },
    "pass": {
    "type": "long"
    },
    "tester": {
    "type": "text"
    },
    "block": {
    "type": "long"
    },
    "refobs": {
    "type": "long"
    },
    "newobs": {
    "type": "long"
    },
    "platform": {
    "type": "text"
    }
    }
    },
    "status": {
    "type": "integer"
    }
    }

    }'

    建好新的索引后,用postman或者curl 进行_reindex 操作

    curl -XPOST http://15.99.72.167:9200/_reindex -d '

    {
    "source": {
    "index": "index_execution"
    },
    "dest": {
    "index": "index_execution_20200414"
    }
    }

    '

    等新索引reindex完成后,通过alias把使用的索引切换到新建的不区分大小写的 index_execution_20200414   上,完成不区分大小写的问题解决

    curl -XPOST http://15.99.72.167:9200/_aliases -d '

    {
    "actions": [
    { "remove": { "index": "index_execution", "alias": "index_execution_active" }},
    { "add": { "index": "index_execution_20200414", "alias": "index_execution_active" }}
    ]
    }

    '

  • 相关阅读:
    关于TextField
    判断一个显示对象是否移除
    不争气的Discuz!NT 3.6和MVC3整合,主要实现同步登录和注册,登出。
    我的博客是英文的
    TFS不提供 Team Foundation 服务的解决办法。
    四 为提高entity framework 性能,要注意哪些事情.
    三 EF 和ado.net 的性能对比.
    一 关于大项目的经验总结
    在.net 中,ajax 如何调用本页数据源
    关于有序guid 的使用
  • 原文地址:https://www.cnblogs.com/xiaohanlin/p/12692741.html
Copyright © 2011-2022 走看看