elasticsearch,Java,elasticsearch" /> elasticsearch,Java,elasticsearch" />

Java 映射中的Elasticsearch-Exeption

Java 映射中的Elasticsearch-Exeption,java,elasticsearch,Java,elasticsearch,我使用Elasticsearch High level client 6.1,当我根据所需值尝试查找一些日志时,会出现以下异常: “原因”:“{”类型“:”异常“,”原因“:”Elasticsearch异常[type=query_shard_异常,原因=未找到[timeStamp]的映射以便进行排序],“index_uuid:”ewqlks3ztdqlgdqfuhi5w“,”索引“:”.kibana“}}],”hits:{”总计“:3,“最大分数”:null,“hits:[{”索引“{”port

我使用Elasticsearch High level client 6.1,当我根据所需值尝试查找一些日志时,会出现以下异常:

“原因”:“{”类型“:”异常“,”原因“:”Elasticsearch异常[type=query_shard_异常,原因=未找到[timeStamp]的映射以便进行排序],“index_uuid:”ewqlks3ztdqlgdqfuhi5w“,”索引“:”.kibana“}}],”hits:{”总计“:3,“最大分数”:null,“hits:[{”索引“{”portal-logs-01.02.2018”,“_类型“:”日志信息“,”vhzugebauny8rf id“:”hits:”,“_score”:null,“_source”:{“timeStamp”:“2018-01-31T15:30:41.000Z”,“header”:“test header 15”,“message”:“test message 34”,“level”:“TRACE”,“node”:“first node”,“system”:“super system 100000”,“port”:9400,“module”:“test module”,“thread”:“test thread”,“operation”:“some operation”,“sessionId”:“1”,“userLogin”:“user”,“userName”:”“用户”,“办公室”:“共52个”,“位置”:{“lat”:41.12,“lon”:-71.34},“ip”:“192.168.3.93”,“设备”:“某些设备”},“排序”:[1517412641000]},{“索引”:“门户-日志-01.02.2018”;“测试类型”:“日志信息”;“测试id”:“Vx5zUGEBAUNy8RN4hRLJ”;“测试分数”:null,“\U源”:{“时间戳”:“2018-01-31T15:30:41.000Z标头”;“测试标头”;“测试标头”;“测试信息”;“跟踪级别”;“34”:节点“:”第一个节点“,”系统“:”超级系统100000“,”端口“:”9400“,”模块“:”测试模块“,”子模块“,”线程“,”测试线程“,”操作“,”一些操作“,”会话ID“,”1“,”用户登录“,”用户“,”用户名“,”用户“,”办公室“,”位置“:{”lat“:”41.12,“lon“:-71.34}”,ip“,”192.168.3.93“,”设备“,”一些设备“,”排序“,”:[1517412641000],”_索引“:”portal-logs-01.02.2018“,”_类型“:”logs_信息“,”_id“:”VR5zUGEBAUNy8RN4fxIq“,”_分数“:”null“,”来源“:”{”时间戳“:”2018-01-31T15:30:41.000Z”,“标头“:”测试标头15”,“消息“:”测试消息34”,“级别“:”跟踪“,”节点“:”第一个节点“,”系统“:”超级系统100000”,“端口“:”9400”,“模块“:”测试模块“,”子模块“:”测试子模块“,”线程“:”测试线程,“操作”:“某些操作”,“会话ID”:“1”,“用户登录”:“用户”,“用户名”:“用户”,“办公室”:“共52个”,“位置”:{“lat”:41.12,“lon”:-71.34},“ip”:“192.168.3.93”,“设备”:“某些设备”},“排序”:[1517412641000]}

这是来自ES服务器的日志:

[2018-02-01T02:46:51,407][DEBUG][o.e.a.s.TransportSearchAction] [node-43] [portal-user-26.01.2018][3], node[SAPKQLGGSJiR8bMBdkNvfQ], [P], s[STARTED], a[id=9d6qWfW3SWaigflL9TCmmw]: Failed to execute [SearchRequest{searchType=QUERY_THEN_FETCH, indices=[], indicesOptions=IndicesOptions[id=38, ignore_unavailable=false, allow_no_indices=true, expand_wildcards_open=true, expand_wildcards_closed=false, allow_aliases_to_multiple_indices=true, forbid_closed_indices=true, ignore_aliases=false], types=[], routing='null', preference='null', requestCache=null, scroll=null, maxConcurrentShardRequests=10, batchedReduceSize=512, preFilterShardSize=128, source={"from":0,"size":20,"query":{"bool":{"filter":[{"match_phrase":{"header":{"query":"test Header 15","slop":0,"boost":1.0}}}],"adjust_pure_negative":true,"boost":1.0}},"sort":[{"timeStamp":{"order":"desc"}}]}}]
org.elasticsearch.transport.RemoteTransportException: [node-70][192.168.3.70:9300][indices:data/read/search[phase/query]]
Caused by: org.elasticsearch.index.query.QueryShardException: No mapping found for [timeStamp] in order to sort on
 at org.elasticsearch.search.sort.FieldSortBuilder.build(FieldSortBuilder.java:319) ~[elasticsearch-6.1.2.jar:6.1.2]
 at org.elasticsearch.search.sort.SortBuilder.buildSort(SortBuilder.java:155) ~[elasticsearch-6.1.2.jar:6.1.2]
 at org.elasticsearch.search.SearchService.parseSource(SearchService.java:718) ~[elasticsearch-6.1.2.jar:6.1.2]
 at org.elasticsearch.search.SearchService.createContext(SearchService.java:552) ~[elasticsearch-6.1.2.jar:6.1.2]
 at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:528) ~[elasticsearch-6.1.2.jar:6.1.2]
 at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:324) ~[elasticsearch-6.1.2.jar:6.1.2]
 at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:310) ~[elasticsearch-6.1.2.jar:6.1.2]
 at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:306) ~[elasticsearch-6.1.2.jar:6.1.2]
 at org.elasticsearch.search.SearchService$3.doRun(SearchService.java:996) ~[elasticsearch-6.1.2.jar:6.1.2]
 at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:637) ~[elasticsearch-6.1.2.jar:6.1.2]
 at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-6.1.2.jar:6.1.2]
 at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41) ~[elasticsearch-6.1.2.jar:6.1.2]
 at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-6.1.2.jar:6.1.2]
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_162]
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_162]
 at java.lang.Thread.run(Thread.java:748) [?:1.8.0_162]
我有这样的映射: 放置模板/门户日志

 {
      "template": "portal-logs-*",
      "settings": { "number_of_shards": 5 },
      "mappings": {
          "logs_info": {
            "_all": {
              "enabled": false
            },
            "properties": {
              "device": {"type": "keyword"},
              "header": {"type": "text"},
              "ip": {"type": "keyword"},
              "level": {"type": "text"},
              "location": {"type": "geo_point"},
              "message": {"type": "text"},
              "module": {"type": "keyword"},
              "node": {"type": "keyword"},
              "office": {"type": "keyword"},
              "operation": {"type": "keyword"},
              "port": {"type": "integer"},
              "sessionId": {"type": "keyword"},
              "submodule": {"type": "keyword"},
              "system": {"type": "keyword"},
              "thread": {"type": "keyword"},
              "timeStamp": {"type": "date"},
              "userLogin": {"type": "keyword"},
              "userName": {"type": "keyword"}
            }
          }
        }
      }
这是代码的一部分:

sourceBuilder.query(bqb)
                    .size(pageable.getPageSize()).from(pageable.getOffset())
                    .sort(new FieldSortBuilder("timeStamp").order(SortOrder.DESC));

实际上,问题是您正在查询所有索引,包括
.kibana
,它没有任何
时间戳
字段,正如错误消息所示

{
  "index": ".kibana",
  "index_uuid": "EwqLKS3ZTDqlGdqfuHHi5w",
  "reason": "Elasticsearch exception [type=query_shard_exception, reason=No mapping found for [timeStamp] in order to sort on]",
  "type": "exception"
}

您应该将您的查询限制在
门户日志-*
索引上,然后它就会成功。

事实上,问题是您正在查询所有索引,包括
.kibana
,正如错误消息所示,它没有任何
时间戳
字段

{
  "index": ".kibana",
  "index_uuid": "EwqLKS3ZTDqlGdqfuHHi5w",
  "reason": "Elasticsearch exception [type=query_shard_exception, reason=No mapping found for [timeStamp] in order to sort on]",
  "type": "exception"
}

你应该把你的查询限制在
门户日志-*
索引上,它会成功的。

你能展示一下你在运行这个时得到了什么吗:
curl-XGET-localhost:9200/portal-logs-01.02.2018
?添加在答案中。你能展示一下你在运行这个时得到了什么吗:
curl-XGET-localhost:9200/portal-logs-01.02.2018
nswers.SearchRequest SearchRequest=new SearchRequest(“门户日志-*”);这很有帮助。谢谢。酷,很高兴它有帮助!还有什么需要关闭此答案的吗?SearchRequest SearchRequest=new SearchRequest(“门户日志-*”);这很有帮助。谢谢。酷,很高兴它有帮助!还有什么需要关闭此答案的吗?