本文整理了Java中org.vertexium.Graph.query()
方法的一些代码示例,展示了Graph.query()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.query()
方法的具体详情如下:
包路径:org.vertexium.Graph
类名称:Graph
方法名:query
[英]Creates a query builder object used to query the graph.
[中]创建用于查询图形的查询生成器对象。
代码示例来源:origin: org.vertexium/vertexium-blueprints
public VertexiumBlueprintsGraphQuery(VertexiumBlueprintsGraph graph, Authorizations authorizations) {
this.graph = graph;
this.q = graph.getGraph().query(authorizations);
this.authorizations = authorizations;
}
代码示例来源:origin: org.visallo/visallo-core
public String search(Graph graph, Authorizations authorizations) {
Query query = graph.query(authorizations).limit(1);
List<Vertex> vertices = Lists.newArrayList(query.vertices());
if (vertices.size() == 0) {
throw new VisalloException("query returned no vertices");
} else if (vertices.size() > 1) {
throw new VisalloException("query returned more than one vertex");
}
return vertices.get(0).getId();
}
代码示例来源:origin: org.visallo/visallo-core
private Vertex findExistingVertexWithHash(String hash, Authorizations authorizations) {
Iterator<Vertex> existingVertices = this.graph.query(authorizations)
.has(VisalloProperties.CONTENT_HASH.getPropertyName(), hash)
.vertices()
.iterator();
if (existingVertices.hasNext()) {
return existingVertices.next();
}
return null;
}
代码示例来源:origin: org.vertexium/vertexium-test
private Map<Object, Long> queryGraphQueryWithTermsAggregation(String queryString, String propertyName, ElementType elementType, Authorizations authorizations) {
Query q = (queryString == null ? graph.query(authorizations) : graph.query(queryString, authorizations)).limit(0);
TermsAggregation agg = new TermsAggregation("terms-count", propertyName);
if (!q.isAggregationSupported(agg)) {
LOGGER.warn("%s unsupported", agg.getClass().getName());
return null;
}
q.addAggregation(agg);
QueryResultsIterable<? extends Element> elements = elementType == ElementType.VERTEX ? q.vertices() : q.edges();
TermsResult aggregationResult = elements.getAggregationResult("terms-count", TermsResult.class);
return termsBucketToMap(aggregationResult.getBuckets());
}
代码示例来源:origin: visallo/vertexium
private Map<Object, Long> queryGraphQueryWithTermsAggregation(String queryString, String propertyName, ElementType elementType, Authorizations authorizations) {
Query q = (queryString == null ? graph.query(authorizations) : graph.query(queryString, authorizations)).limit(0);
TermsAggregation agg = new TermsAggregation("terms-count", propertyName);
if (!q.isAggregationSupported(agg)) {
LOGGER.warn("%s unsupported", agg.getClass().getName());
return null;
}
q.addAggregation(agg);
QueryResultsIterable<? extends Element> elements = elementType == ElementType.VERTEX ? q.vertices() : q.edges();
TermsResult aggregationResult = elements.getAggregationResult("terms-count", TermsResult.class);
return termsBucketToMap(aggregationResult.getBuckets());
}
代码示例来源:origin: org.vertexium/vertexium-test
private StatisticsResult queryGraphQueryWithStatisticsAggregation(String propertyName, Authorizations authorizations) {
Query q = graph.query(authorizations).limit(0);
StatisticsAggregation agg = new StatisticsAggregation("stats", propertyName);
if (!q.isAggregationSupported(agg)) {
LOGGER.warn("%s unsupported", StatisticsAggregation.class.getName());
return null;
}
q.addAggregation(agg);
return q.vertices().getAggregationResult("stats", StatisticsResult.class);
}
代码示例来源:origin: visallo/vertexium
private CardinalityResult queryGraphQueryWithCardinalityAggregation(String propertyName, Authorizations authorizations) {
Query q = graph.query(authorizations).limit(0);
CardinalityAggregation agg = new CardinalityAggregation("card", propertyName);
if (!q.isAggregationSupported(agg)) {
LOGGER.warn("%s unsupported", CardinalityAggregation.class.getName());
return null;
}
q.addAggregation(agg);
return q.vertices().getAggregationResult("card", CardinalityResult.class);
}
代码示例来源:origin: org.vertexium/vertexium-blueprints
@Override
public Iterable<Vertex> getVertices(final String key, final Object value) {
final Authorizations authorizations = getAuthorizationsProvider().getAuthorizations();
return new ConvertingIterable<org.vertexium.Vertex, Vertex>(getGraph().query(authorizations).has(key, Compare.EQUAL, value).vertices(getFetchHints())) {
@Override
protected Vertex convert(org.vertexium.Vertex vertex) {
return VertexiumBlueprintsVertex.create(VertexiumBlueprintsGraph.this, vertex, authorizations);
}
};
}
代码示例来源:origin: org.vertexium/vertexium-blueprints
@Override
public Iterable<Edge> getEdges(final String key, final Object value) {
final Authorizations authorizations = getAuthorizationsProvider().getAuthorizations();
return new ConvertingIterable<org.vertexium.Edge, Edge>(getGraph().query(authorizations).has(key, Compare.EQUAL, value).edges(getFetchHints())) {
@Override
protected Edge convert(org.vertexium.Edge edge) {
return VertexiumBlueprintsEdge.create(VertexiumBlueprintsGraph.this, edge, authorizations);
}
};
}
代码示例来源:origin: org.vertexium/vertexium-test
private Map<String, Long> queryGraphQueryWithGeohashAggregation(String propertyName, int precision, Authorizations authorizations) {
Query q = graph.query(authorizations).limit(0);
GeohashAggregation agg = new GeohashAggregation("geo-count", propertyName, precision);
if (!q.isAggregationSupported(agg)) {
LOGGER.warn("%s unsupported", GeohashAggregation.class.getName());
return null;
}
q.addAggregation(agg);
return geoHashBucketToMap(q.vertices().getAggregationResult("geo-count", GeohashResult.class).getBuckets());
}
代码示例来源:origin: visallo/vertexium
private Map<String, Long> queryGraphQueryWithGeohashAggregation(String propertyName, int precision, Authorizations authorizations) {
Query q = graph.query(authorizations).limit(0);
GeohashAggregation agg = new GeohashAggregation("geo-count", propertyName, precision);
if (!q.isAggregationSupported(agg)) {
LOGGER.warn("%s unsupported", GeohashAggregation.class.getName());
return null;
}
q.addAggregation(agg);
return geoHashBucketToMap(q.vertices().getAggregationResult("geo-count", GeohashResult.class).getBuckets());
}
代码示例来源:origin: org.visallo/visallo-model-vertexium
@Override
public Iterable<Relationship> getRelationshipsByIRI(List<String> relationshipIRIs, String workspaceId) {
QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId))
.has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_RELATIONSHIP)
.has(OntologyProperties.ONTOLOGY_TITLE.getPropertyName(), Contains.IN, relationshipIRIs)
.vertices();
return transformRelationships(vertices, workspaceId);
}
代码示例来源:origin: org.visallo/visallo-model-vertexium
@Override
protected List<Concept> findLoadedConceptsByIntent(String intent, String workspaceId) {
QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId))
.has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_CONCEPT)
.has(OntologyProperties.INTENT.getPropertyName(), intent)
.vertices();
return transformConcepts(vertices, workspaceId);
}
代码示例来源:origin: org.visallo/visallo-model-vertexium
@Override
public Iterable<Concept> getConceptsByIRI(List<String> conceptIRIs, String workspaceId) {
QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId))
.has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_CONCEPT)
.has(OntologyProperties.ONTOLOGY_TITLE.getPropertyName(), Contains.IN, conceptIRIs)
.vertices();
return transformConcepts(vertices, workspaceId);
}
代码示例来源:origin: org.visallo/visallo-model-vertexium
@Override
protected List<Relationship> findLoadedRelationshipsByIntent(String intent, String workspaceId) {
QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId))
.has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_RELATIONSHIP)
.has(OntologyProperties.INTENT.getPropertyName(), intent)
.vertices();
return transformRelationships(vertices, workspaceId);
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testGraphQueryVertexHasWithSecurityCantSeeProperty() {
graph.prepareVertex("v1", VISIBILITY_A)
.setProperty("age", 25, VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A)
.has("age", Compare.EQUAL, 25)
.vertices();
Assert.assertEquals(0, count(vertices));
}
代码示例来源:origin: org.visallo/visallo-model-vertexium
@Override
public Iterable<OntologyProperty> getPropertiesByIRI(List<String> propertyIRIs, String workspaceId) {
QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId))
.has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_PROPERTY)
.has(OntologyProperties.ONTOLOGY_TITLE.getPropertyName(), Contains.IN, propertyIRIs)
.vertices();
return transformProperties(vertices, workspaceId);
}
代码示例来源:origin: org.visallo/visallo-model-vertexium
@Override
public List<OntologyProperty> getPropertiesByIntent(String intent, String workspaceId) {
QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId))
.has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_PROPERTY)
.has(OntologyProperties.INTENT.getPropertyName(), intent)
.vertices();
return transformProperties(vertices, workspaceId);
}
代码示例来源:origin: visallo/vertexium
@Test
public void testExtendedDataDelete() {
graph.prepareVertex("v1", VISIBILITY_A)
.addExtendedData("table1", "row1", "name", "value", VISIBILITY_A)
.save(AUTHORIZATIONS_A);
graph.flush();
graph.deleteVertex("v1", AUTHORIZATIONS_A);
graph.flush();
QueryResultsIterable<? extends VertexiumObject> searchResults = graph.query("value", AUTHORIZATIONS_A)
.search();
assertEquals(0, searchResults.getTotalHits());
}
代码示例来源:origin: visallo/vertexium
@Test
public void testQueryReturningElasticsearchVertex() {
graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
graph.addVertex("v2", VISIBILITY_B, AUTHORIZATIONS_B);
graph.addEdge("e1", "v1", "v2", LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
graph.flush();
QueryResultsIterable<Vertex> vertices = graph.query(AUTHORIZATIONS_B)
.vertices(FetchHints.NONE);
assertResultsCount(1, 1, vertices);
Vertex vertex = toList(vertices).get(0);
assertEquals("v2", vertex.getId());
}
内容来源于网络,如有侵权,请联系作者删除!