मुझे लोचदार खोज चलने का एक इन-मेमोरी इंस्टेंस मिला है, और खोज जावा एपीआई सीखने के लिए कुछ अन्वेषण कोडिंग कर रहा है। मैं इंडेक्स में दस्तावेज जमा करने और जीईटी का उपयोग करके उन्हें पुनः प्राप्त करने में सक्षम हूं, लेकिन जब मैं एक साधारण खोज क्वेरी का प्रयास करता हूं, तो मुझे कोई परिणाम नहीं मिल रहा है।elasticsearch java API: matchAll खोज क्वेरी परिणाम नहीं लौटाती है?
// first, try a get request, to make sure there is something in the index
GetResponse results = client.prepareGet(INDEX_NAME, INDEX_TYPE, testID)
.execute()
.actionGet();
// this assertion succeeds, as we expect it to.
assertThat(results.getId()).isEqualTo(testID);
// next, try the simplest possible search
SearchResponse s1 = client.prepareSearch(INDEX_NAME).setQuery(matchAllQuery())
.execute()
.actionGet();
// this assertion fails. why? answer: when we have an in-memory node, we have to
// manually call refresh on the indexing, after submitting a document.
assertThat(s1.getHits().totalHits()).isGreaterThanOrEqualTo(1);
कुछ परीक्षण के बाद, मुझे लगता है कि समस्या यह है कि मैं अपने नोड और संबद्ध ग्राहक (स्मृति में) की स्थापना कर रहा हूँ में है:
लोचदार खोज गूगल समूह पर@BeforeMethod
public void setup() {
// set up elastic search to run locally. since the transaction
// log needs a filesystem, we can't run it as purely in memory,
// but we can set the data directories into "target", so that maven will
// clean up after the fact: http://bit.ly/OTN7Qf
Settings settings = ImmutableSettings.settingsBuilder()
.put("node.http.enabled", true)
.put("path.logs","target/elasticsearch/logs")
.put("path.data","target/elasticsearch/data")
.put("gateway.type", "none")
.put("index.store.type", "memory")
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 1).build();
node = NodeBuilder.nodeBuilder().local(true).settings(settings).node();
client = node.client();
}
इसे यहां पोस्ट करने के लिए धन्यवाद! मुझे घंटे बचाया! – Alebon
हां, ईएस निकट-वास्तविक समय है - पारंपरिक एसक्यूएल डेटाबेस की तरह तत्काल नहीं। – bradvido