use of org.janusgraph.diskstorage.BaseTransactionConfig in project janusgraph by JanusGraph.
the class ElasticSearchConfigTest method simpleWriteAndQuery.
private void simpleWriteAndQuery(IndexProvider idx) throws BackendException, InterruptedException {
final Duration maxWrite = Duration.ofMillis(2000L);
final String storeName = "jvmlocal_test_store";
final KeyInformation.IndexRetriever indexRetriever = IndexProviderTest.getIndexRetriever(IndexProviderTest.getMapping(idx.getFeatures(), ANALYZER_STANDARD, ANALYZER_KEYWORD));
final BaseTransactionConfig txConfig = StandardBaseTransactionConfig.of(TimestampProviders.MILLI);
IndexTransaction itx = new IndexTransaction(idx, indexRetriever, txConfig, maxWrite);
for (final Entry<String, KeyInformation> entry : IndexProviderTest.getMapping(idx.getFeatures(), "english", "keyword").entrySet()) {
idx.register(storeName, entry.getKey(), entry.getValue(), itx);
}
assertEquals(0, itx.queryStream(new IndexQuery(storeName, PredicateCondition.of(IndexProviderTest.NAME, Text.PREFIX, "ali"))).count());
itx.add(storeName, "doc", IndexProviderTest.NAME, "alice", false);
itx.commit();
// Slightly longer than default 1s index.refresh_interval
Thread.sleep(1500L);
itx = new IndexTransaction(idx, indexRetriever, txConfig, maxWrite);
assertEquals(0, itx.queryStream(new IndexQuery(storeName, PredicateCondition.of(IndexProviderTest.NAME, Text.PREFIX, "zed"))).count());
assertEquals(1, itx.queryStream(new IndexQuery(storeName, PredicateCondition.of(IndexProviderTest.NAME, Text.PREFIX, "ali"))).count());
itx.rollback();
}
Aggregations