INFO-离线开发代码搜索

使用场景
离线开发代码搜索
使用示例

离线开发代码搜索页面展示与客户预期不符,可以后台查询是否符合预期,使用es查询逻辑

开启模糊搜索
curl -XPOST -u elastic:Elasticsearch@1024.com "ip:port/mammut_project_mapping_v2/_search" -H 'Content-Type: application/json' -d'
{
  "query" : {
    "bool" : {
      "must" : [
        {
          "terms" : {
            "product" : [
              "xxx"//项目名
            ],
            "boost" : 1.0
          }
        },
        {
          "terms" : {
            "clusterId" : [
              "xxx"//集群名
            ],
            "boost" : 1.0
          }
        },
        {
          "match" : {
            "rawText" : {
              "query" : "xxx",//关键字
              "operator" : "OR",
              "prefix_length" : 0,
              "max_expansions" : 50,
              "minimum_should_match" : "25%",
              "fuzzy_transpositions" : true,
              "lenient" : false,
              "zero_terms_query" : "NONE",
              "boost" : 1.0
            }
          }
        }
      ],
      "adjust_pure_negative" : true,
      "boost" : 1.0
    }
  }
}'
精准搜索
curl -XPOST -u elastic:Elasticsearch@1024.com "ip:port/mammut_project_mapping_v2/_search" -H 'Content-Type: application/json' -d'
{
  "query" : {
    "bool" : {
      "must" : [
        {
          "terms" : {
            "product" : [
              "xxx"//项目名
            ],
            "boost" : 1.0
          }
        },
        {
          "terms" : {
            "clusterId" : [
              "xxx"//集群名
            ],
            "boost" : 1.0
          }
        },
        {
          "match_phrase" : {
            "rawText" : {
              "query" : "xxx",//关键字
              "slop" : 0,
              "boost" : 1.0
            }
          }
        }
      ],
      "adjust_pure_negative" : true,
      "boost" : 1.0
    }
  }
}'

作者:常惠渊