use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project sqlg by pietermartin.
the class TestEdgeHas method testEdgeHas.
@Test
public void testEdgeHas() {
Vertex stephen = this.sqlgGraph.addVertex("name", "stephen");
Vertex marko = this.sqlgGraph.addVertex("name", "marko");
stephen.addEdge("knows", marko, "weight", 1.0d);
stephen.addEdge("knows", marko, "weight", 2.0d);
this.sqlgGraph.tx().commit();
GraphTraversal knows = vertexTraversal(this.sqlgGraph, stephen).outE("knows");
knows.has("weight", 1.0d);
Assert.assertEquals(1L, knows.count().next());
Assert.assertEquals(1, vertexTraversal(this.sqlgGraph, stephen).outE("knows").has("weight", 1.0d).count().next(), 0);
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class DerivedListFacetDescription method filter.
@Override
public void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facets) {
Optional<FacetValue> first = facets.stream().filter(facetValue -> Objects.equals(facetValue.getName(), facetName)).findFirst();
if (!first.isPresent()) {
return;
}
FacetValue facetValue = first.get();
if (!(facetValue instanceof ListFacetValue)) {
return;
}
List<String> values = ((ListFacetValue) facetValue).getValues();
if (values.isEmpty()) {
return;
}
graphTraversal.where(__.bothE(relations).otherV().bothE(relationNames).otherV().values(propertyName).map(value -> parser.parse((String) value.get())).is(within(values)));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class Neo4JIndexHandlerTest method findKeywordsByQuickSearchDoesNotFilterOnKeywordTypeWhenKeywordtypesIsNull.
@Test
public void findKeywordsByQuickSearchDoesNotFilterOnKeywordTypeWhenKeywordtypesIsNull() {
String id1 = UUID.randomUUID().toString();
String id2 = UUID.randomUUID().toString();
String id3 = UUID.randomUUID().toString();
TinkerPopGraphManager tinkerPopGraphManager = newGraph().withVertex(v -> v.withTimId(id1).withProperty("keyword_type", "keywordType").withProperty("displayName", "query")).withVertex(v -> v.withProperty("keyword_type", "otherType").withTimId(id2).withProperty("displayName", "query2")).withVertex(v -> v.withProperty("keyword_type", "otherType").withTimId(id3).withProperty("displayName", "notmatching")).wrap();
Neo4jIndexHandler instance = new Neo4jIndexHandler(tinkerPopGraphManager);
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id1).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id2).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id3).next());
QuickSearch quickSearch = QuickSearch.fromQueryString("query");
GraphTraversal<Vertex, Vertex> vertices = instance.findKeywordsByQuickSearch(collection, quickSearch, null);
assertThat(vertices.map(v -> v.get().value("tim_id")).toList(), containsInAnyOrder(id1, id2));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class Neo4JIndexHandlerTest method findKeywordsByQuickSearchFiltersTheIndexResultsOnTheRightKeywordType.
@Test
public void findKeywordsByQuickSearchFiltersTheIndexResultsOnTheRightKeywordType() {
String id1 = UUID.randomUUID().toString();
String id2 = UUID.randomUUID().toString();
String id3 = UUID.randomUUID().toString();
TinkerPopGraphManager tinkerPopGraphManager = newGraph().withVertex(v -> v.withTimId(id1).withProperty("keyword_type", "keywordType").withProperty("displayName", "query")).withVertex(v -> v.withProperty("keyword_type", "otherType").withTimId(id2).withProperty("displayName", "query2")).withVertex(v -> v.withProperty("keyword_type", "otherType").withTimId(id3).withProperty("displayName", "notmatching")).wrap();
Neo4jIndexHandler instance = new Neo4jIndexHandler(tinkerPopGraphManager);
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id1).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id2).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id3).next());
QuickSearch quickSearch = QuickSearch.fromQueryString("query");
GraphTraversal<Vertex, Vertex> vertices = instance.findKeywordsByQuickSearch(collection, quickSearch, "keywordType");
assertThat(vertices.map(v -> v.get().value("tim_id")).toList(), containsInAnyOrder(id1));
}
use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.
the class Neo4JIndexHandlerTest method removeFromQuickSearchIndexRemovesTheVertexFromTheIndex.
@Test
public void removeFromQuickSearchIndexRemovesTheVertexFromTheIndex() {
String id1 = UUID.randomUUID().toString();
TinkerPopGraphManager tinkerPopGraphManager = newGraph().withVertex(v -> v.withTimId(id1)).wrap();
Neo4jIndexHandler instance = new Neo4jIndexHandler(tinkerPopGraphManager);
Vertex vertex = tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id1).next();
instance.upsertIntoQuickSearchIndex(collection, "query", vertex, null);
GraphTraversal<Vertex, Vertex> beforeRemoval = instance.findByQuickSearch(collection, QuickSearch.fromQueryString("query"));
assertThat(beforeRemoval.hasNext(), is(true));
instance.removeFromQuickSearchIndex(collection, vertex);
GraphTraversal<Vertex, Vertex> afterRemoval = instance.findByQuickSearch(collection, QuickSearch.fromQueryString("query"));
assertThat(afterRemoval.hasNext(), is(false));
}
Aggregations