elasticsearch-query 收到查询的 0 条记录

elasticsearch-query receiving 0 records for a query

我收到以下查询的 0 条记录:

{ 
  "query": {
    "term": {
      "appInfo.additionalInfo.DeviceID": "84A29458-C63F-4875-AFD0-0BD9E19559B3"       
    }
  }
}

另外,下面查询returns 0条记录:

{ 
  "query": {
    "term": {
      "appInfo.additionalInfo.DeviceID.keyword": "84A29458-C63F-4875-AFD0-0BD9E19559B3"       
    }
  }
}

数据为:

{
  "userInfo": {
    "additionalInfo": {
      "DeviceID": "84A29458-C63F-4875-AFD0-0BD9E19559B3"
    }
  }
}

映射为:

{
  "properties": {
    "userInfo": {
      "properties": {
        "additionalInfo": {
          "properties": {
            "DeviceID": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            }
          }
        }
      }
    }
  }
}

您需要查询 userInfo.additionalInfo.DeviceID 字段。将您的搜索查询修改为

{ 
  "query": {
    "term": {
      "userInfo.additionalInfo.DeviceID.keyword": "84A29458-C63F-4875-AFD0-0BD9E19559B3"       
    }
  }
}