使用通配符的ElasticSearch LIKE查询

时间:2019-12-04 07:19:49

标签: java elasticsearch

类似的东西,我正在尝试实现低于JSON。

SELECT * FROM TABLE_NAME,其中ORGID =“ BACKENDORG” AND TYPE =“ AUDIT” AND
(sessionId LIKE'%16ECA064B298356B%'或loginUserId LIKE'%16ECA064B298356B%'或txnId LIKE'%16ECA064B298356B%');

{
  "sessionId": "16ECA064B298356B",
  "message": "2019-12-03T05:29:13.217Z [http-nio-8080-exec-4] INFO  http-nio-8080-exec-4 QueryController backendorg 16CFAFCCFB14D9A3 16ECA064B298356B 16ECA3A4EFA026BF 
  "type": "audit",
  "orgId": "backendorg",
  "loginUserId": "16CFAFCCFB14D9A3",
  "txnId": "16ECA3A4EFA026BF"
 }

尝试使用BoolQueryBuilder编写LIKE查询,这是我的查询

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "orgId": {
              "value": "backendorg",
              "boost": 1
            }
          }
        },
        {
          "term": {
            "type": {
              "value": "audit",
              "boost": 1
            }
          }
        },
        {
          "bool": {
            "should": [
              {
                "wildcard": {
                  "sessionId": {
                    "wildcard": "16ECA064B298356B",
                    "boost": 1
                  }
                }
              },
              {
                "wildcard": {
                  "loginUserId": {
                    "wildcard": "16ECA064B298356B",
                    "boost": 1
                  }
                }
              },
              {
                "wildcard": {
                  "txnId": {
                    "wildcard": "16ECA064B298356B",
                    "boost": 1
                  }
                }
              }
            ],
            "adjust_pure_negative": true,
            "minimum_should_match": "1",
            "boost": 1
          }
        }
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  }
}

以上查询应返回上述JSON结果,但显示为零。 如果有人指出了问题,将会很有帮助。

0 个答案:

没有答案