如何在elasticsearch 5.1中获取指定的字段(使用curl)?

时间:2017-01-23 06:10:28

标签: curl elasticsearch

我想在elasticsearch 5.1中获取指定的字段。 例如 从表

中选择x,y

示例文档

{
  "_index": "logstash-2017.01.05",
  "_type": "logs",
  "_id": "AVltoGqz-zTtgAXZybOK",
  "_version": 1,
  "found": true,
  "_source": {
    "sourcePORT": "55645",
    "EndTime": "2016-11-08T03:00:43.033",
    "StartTime": "2016-11-08T03:00:43.033",
    "message": "10.215.56.162,55645,161.202.1.13,443,base.ip.tcp,2016-11-08T03:00:43.033,2016-11-08T03:00:43.033,0,74,0.000000,0,0-0:",
    "DestinationPORT": "443",
    "tags": [],
    "path": "C:/Users/akshay.patil/Desktop/DataDump01.csv",
    "DestinationIP": "161.202.1.13",
    "@timestamp": "2017-01-05T07:55:46.710Z",
    "sourceIP": "10.215.56.162",
    "received_at": "2017-01-05T07:55:46.710Z",
    "@version": "1",
    "host": "3299D11",
    "ProtocolPath": "base.ip.tcp"
  }
}

2 个答案:

答案 0 :(得分:0)

很简单,您可以像这样使用source filtering

private Camera.Size getOptimalPreviewSize(List<Camera.Size> sizes, int w, int h) {

    if (sizes==null) return null;

    Camera.Size optimalSize = null;
    double ratio = (double)h/w;
    double minDiff = Double.MAX_VALUE;
    double newDiff;
    for (Camera.Size size : sizes) {
        newDiff = Math.abs((double)size.width/size.height - ratio);
        if (newDiff < minDiff) {
            optimalSize = size;
            minDiff = newDiff;
        }
    }
    return optimalSize;
}

答案 1 :(得分:0)

这将返回您要打印的特定字段

if (inputUrl == "stackoverflow.com") { console.log ("stackoverflow"); } else { console.log("not stackoverflow"); }