Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
175 views
in Technique[技术] by (71.8m points)

elasticsearch-query receiving 0 records for a query

I'm receiving 0 records for the following query:

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

Also, the following query returns 0 records:

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

The data is:

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

The mapping is:

{
  "properties": {
    "userInfo": {
      "properties": {
        "additionalInfo": {
          "properties": {
            "DeviceID": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            }
          }
        }
      }
    }
  }
}
question from:https://stackoverflow.com/questions/66048778/elasticsearch-query-receiving-0-records-for-a-query

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to query against userInfo.additionalInfo.DeviceID field. Modify your search query as

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...