您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何在elasticsearch中正确编写布尔值或逻辑?

如何在elasticsearch中正确编写布尔值或逻辑?

您无法获得结果的主要原因是因为您试图对进行term过滤actionType,这是一个已分析的字段。如果要term对该字段进行匹配,则需要更新类型映射以将该字段设置为not_analyzed。请参见以下示例映射:

{
   "record": {
      "properties": {
         "actionType": {
            "type": "string",
            "index": "not_analyzed",
         },
         "loId": {
            "type": "long"
         },
         "paId": {
            "type": "long"
         },
         "prId": {
            "type": "long"
         },
         "timestamp": {
            "type": "long"
         },
         "uid": {
            "type": "long"
         },
         "vId": {
            "type": "long"
         }
      }
   }
}

从此处开始阅读有关映射的信息:http ://www.elasticsearch.org/guide/reference/mapping/。您需要重新索引数据。修复该问题后,下面的查询将起作用:

{ 
    "query": { 
        "filtered": {
           "query": {"match_all":{}},
           "filter": {
               "bool": {
                   "must": [
                       {"term": {"loId":6}},
                       {
                           "or": [
                               {"term":{"actionType": "SAVE_DATA"}},
                               {"term":{"actionType": "OPEN_SCREEN"}}
                           ]
                       }
                   ]
               }
           }
        }
    }
}
其他 2022/1/1 18:17:17 有431人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶