- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在运行我的第一个 elasticsearch 测试用例,我使用 Java 作为解决方案的角度来做 elasticsearch 实验。它在 eclipse Debug模式下工作得很好,
Debug模式结果:
{postDate=2016-01-31T10:32:58.952Z, title=Posting, content=today's weather is hot, tags=[hashtag]}
但是当我在正常运行应用程序模式下尝试这个时,我收到以下异常并且我完全不知道。请指导我。
以下异常:
8253 [main] INFO org.elasticsearch.node - [Marc Spector] started
8257 [elasticsearch[Marc Spector][clusterService#updateTask][T#1]] DEBUG org.elasticsearch.index.store - [Marc Spector] [facebook] using index.store.throttle.type [none], with index.store.throttle.max_bytes_per_sec [0b]
8273 [elasticsearch[Marc Spector][search][T#4]] DEBUG org.elasticsearch.action.search.type - [Marc Spector] All shards failed for phase: [query]
RemoteTransportException[[Marc Spector][127.0.0.1:9300][indices:data/read/search[phase/query]]]; nested: IndexNotFoundException[no such index];
Caused by: [facebook] IndexNotFoundException[no such index]
at org.elasticsearch.indices.IndicesService.indexServiceSafe(IndicesService.java:310)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:635)
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:617)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:368)
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.TransportService$4.doRun(TransportService.java:350)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "main" Failed to execute phase [query], all shards failed
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:228)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$1.onFailure(TransportSearchTypeAction.java:174)
at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:46)
at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:821)
at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:799)
at org.elasticsearch.transport.TransportService$4.onFailure(TransportService.java:361)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
8278 [elasticsearch[Marc Spector][clusterService#updateTask][T#1]] DEBUG org.elasticsearch.index.mapper - [Marc Spector] [facebook] using dynamic[true]
我认为显示源代码可以更清楚地说明问题
来源:
Node node = nodeBuilder().clusterName("testing2").node();
Client client = node.client();
SearchResponse response = client.prepareSearch("facebook")
.setTypes("Lance")
.setSearchType(SearchType.QUERY_THEN_FETCH)
.setQuery(QueryBuilders.matchPhrasePrefixQuery("title", "Pos"))
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();
SearchHit[] searchResponse = response.getHits().getHits();
for(SearchHit hit : searchResponse){
System.out.println(hit.getSource());
}
最佳答案
在查询你的facebook索引之前,你需要先创建它:
Settings indexSettings = ImmutableSettings.settingsBuilder()
.put("number_of_shards", 5)
.put("number_of_replicas", 1)
.build();
CreateIndexRequest indexRequest = new CreateIndexRequest("facebook", indexSettings);
client.admin().indices().create(indexRequest).actionGet();
如果您希望找到一些结果,您还需要索引您的数据:
IndexResponse response = client.prepareIndex("facebook", "Lance", "1")
.setSource(jsonBuilder()
.startObject()
.field("title", "Posting")
.field("postDate", new Date())
.field("content", "today's weather is hot")
.field("tags", Lists.newArrayList("hashtag"))
.endObject()
)
.execute()
.actionGet();
然后您可以在您的索引上进行搜索。
关于java - IndexNotFoundException[没有这样的索引],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35113565/
我正在运行我的第一个 elasticsearch 测试用例,我使用 Java 作为解决方案的角度来做 elasticsearch 实验。它在 eclipse Debug模式下工作得很好, Debug模
我有以下代码试图捕获空引用。然后它会抛出异常,并为消息属性中指定的错误提供更明确的原因。 它应该抛出什么类型的异常? IndexOutOfRangeException? var existing =
我创建了一个java客户端来连接到elasticsearch并请求多个名为analytics-%{+YYYY.MM.dd}的索引中的文档。这是我的代码: try { client = Tran
我自己编写代码来索引一些数据文件。这一切都在起作用。一旦我修改了 schema.xml文件,现在我收到内部服务器错误,我不知道如何解释它。 Internal Server Error request:
我是 ELK 的新手。我在用 :- elasticsearch-2.1.0- logstash-2.1.1- kibana-4.3.0-windows我尝试配置 ELK 以监视我的应用程序日志,并且遵
我是 Java 和 Lucene 的新手。我的代码从文件中获取一行并将其存储在 Lucene Index 中。但是当我创建一个 IndexReader 来搜索和读取索引时,它会抛出一个异常。 我的ja
我是一名优秀的程序员,十分优秀!