如何搜索Elasticsearch

时间:2017-07-19 06:26:32

标签: elasticsearch kibana

我有一个弹性搜索群集,其中有1000多个索引,我的大多数索引都有特定时间戳,但是很少有索引在UTC中有时间戳,当有人试图从kibana搜索时导致查询崩溃,我试图列出所有没有名为ts的字段的索引,我可以通过curl获得字段映射 culr -XGET http://es-node1:9200/ * / _ mapping / field / ts?pretty

然而,通过所有1000多个结果是非常繁琐的,有人请指出我正确的查询以排除所有没有字段“ts”的索引

如果我从群集中的kibana节点运行查询,则启动sppu cpu,我正在运行的过滤器

"filter": {
  "list": {
    "0": {
      "type": "time",
      "field": "ts",
      "from": "now-5m",
      "to": "now",
      "mandate": "must",
      "active": true,
      "alias": "",
      "id": 0
    },
    "1": {
      "type": "querystring",
      "query": "_exists_:ts",
      "mandate": "must",
      "active": true,
      "alias": "",
      "id": 1
    }
  },
  "ids": [
    0,
    1
  ],
  "hide": true
}

},

这是我在ES节点中获取的日志。

[2017-07-19 06:35:12,874][DEBUG][action.search            ] [Gargoyle] [ws][4], node[FbXhw2ERQT6QDPmNCuOMGQ], [R], v[21], s[STARTED], a[id=iH_6483qRHmJGSk95rOtQg]: Failed to execute [org.elasticsearch.action.search.SearchRequest@4078c587] lastShard [true]

RemoteTransportException [[美国队长] [es-node1:9300] [indices:data / read / search [phase / query]]];嵌套:SearchParseException [无法解析搜索源[{“query”:{“filtered”:{“query”:{“bool”:{“should”:[{“query_string”:{“query”:“ “}}]}},” 过滤器 “:{” 布尔 “:{” 必须 “:[{” 范围 “:{” TS “:{” 从 “:1500445811001,” 到 “:1500446111001}}},{” fquery “:{” 查询 “:{” QUERY_STRING “:{” 查询 “:” TS:(1500446010000) “},” _缓存 “:真正}}]}}}},” 亮点 “:{” 田“: {}, “fragment_size”:2147483647, “pre_tags”:[ “@开始高亮@”], “post_tags”:[ “@端高亮@”]}, “大小”:1000, “排序”:[{ “_score”:{ “顺序”: “降序”}},{ “TS”:{ “顺序”: “降序”}}]}]];嵌套:SearchParseException [找不到[ts]的映射以进行排序]; 引起:SearchParseException [无法解析搜索源[{“query”:{“filtered”:{“query”:{“bool”:{“should”:[{“query_string”:{“query”:“ “}}]}},” 过滤器 “:{” 布尔 “:{” 必须 “:[{” 范围 “:{” TS “:{” 从 “:1500445811001,” 到“:1500446111001}}}, { “fquery”:{ “查询”:{ “QUERY_STRING”:{ “查询”: “TS:(1500446010000)”}, “_缓存”:真正}}]}}}}, “亮点”:{“领域“:{},” fragment_size “:2147483647,” pre_tags “:[” @开始高亮@ “],” post_tags “:[” @端高亮@ “]},” 大小 “:1000,” 排序“: [{ “_score”:{ “顺序”: “降序”}},{ “TS”:{ “顺序”: “降序”}}]}]];嵌套:SearchParseException [找不到[ts]的映射以进行排序];     在org.elasticsearch.search.SearchService.parseSource(SearchService.java:855)     在org.elasticsearch.search.SearchService.createContext(SearchService.java:654)     在org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:620)     在org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:371)     at org.elasticsearch.search.action.SearchServiceTransportAction $ SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:368)     at org.elasticsearch.search.action.SearchServiceTransportAction $ SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:365)     at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33)     at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:75)     at org.elasticsearch.transport.netty.MessageChannelHandler $ RequestHandler.doRun(MessageChannelHandler.java:300)     在org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)     在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)     at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)     在java.lang.Thread.run(Thread.java:745) 引起:SearchParseException [没有找到[ts]的映射以便排序]     at org.elasticsearch.search.sort.SortParseElement.addSortField(SortParseElement.java:212)     at org.elasticsearch.search.sort.SortParseElement.addCompoundSortField(SortParseElement.java:186)     at org.elasticsearch.search.sort.SortParseElement.parse(SortParseElement.java:84)     在org.elasticsearch.search.SearchService.parseSource(SearchService.java:838)     ......还有12个

我正在尝试删除其中没有字段“ts”的索引,因为我正在寻找一个查询,我只能得到没有字段ts的索引,有人可以请帮助我查询?

1 个答案:

答案 0 :(得分:0)

在Kibana中,您可以使用_exists_ query并在查询中添加以下内容

_exists_:ts AND ...the rest of your query