我坚持使用elasticsearch搜索API。谁能告诉我我在这里做错了什么?不能使搜索API工作Elasticsearch不返回Java搜索API中的任何匹配
我使用的测试类从elasticsearch 1.0.1
1.Get客户
Client testClient = ElasticsearchIntegrationTest.client();
2.插入一些数据
client.prepareIndex("elastic_index", "elastic_type", "1")
.setSource(jsonBuilder()
.startObject()
.field("ID", "1")
.field("value", "big")
.endObject())
.execute()
.actionGet();
3。获取插入数据(此作品)
GetResponse response = client.prepareGet("elastic_index", "elastic_type", "1")
.execute()
.actionGet();
4.搜索插入的数据(这不起作用)。
SearchResponse searchResponse = client.prepareSearch("elastic_index")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(matchQuery("value", "big"))
.setFrom(0).setSize(60).setExplain(true)
.setTypes("elastic_type")
.execute()
.actionGet();
我试过各种QueryBuilders没有运气。返回的匹配数总是零。
当从一个集成测试中运行('ESIntegTestCase'),'this.refresh()'也一样。 –