@Override protected List<FilterBuilder> getFilters(String elementType) { List<FilterBuilder> filters = super.getFilters(elementType); AuthorizationFilterBuilder authorizationFilterBuilder = new AuthorizationFilterBuilder(getParameters().getAuthorizations().getAuthorizations()); filters.add(authorizationFilterBuilder); return filters; }
private List<String> getFieldNames( Graph graph, Elasticsearch5SearchIndex searchIndex, QueryParameters queryParameters, String field ) { PropertyDefinition propertyDefinition = graph.getPropertyDefinition(field); if (propertyDefinition == null) { return null; } if (!searchIndex.isPropertyInIndex(graph, field)) { return null; } String[] propertyNames = searchIndex.getPropertyNames( graph, propertyDefinition.getPropertyName(), queryParameters.getAuthorizations() ); return Arrays.stream(propertyNames) .filter(propertyName -> Number.class.isAssignableFrom(propertyDefinition.getDataType())) .collect(Collectors.toList()); } }
@SuppressWarnings("unchecked") private <T extends Element> Iterable<T> getIterableFromElementType(ElementType elementType, FetchHints fetchHints) throws VertexiumException { switch (elementType) { case VERTEX: return (Iterable<T>) getGraph().getVertices(fetchHints, getParameters().getAuthorizations()); case EDGE: return (Iterable<T>) getGraph().getEdges(fetchHints, getParameters().getAuthorizations()); default: throw new VertexiumException("Unexpected element type: " + elementType); } }
@SuppressWarnings("unchecked") private <T extends Element> Iterable<T> getIterableFromElementType(ElementType elementType, FetchHints fetchHints) throws VertexiumException { switch (elementType) { case VERTEX: return (Iterable<T>) getGraph().getVertices(fetchHints, getParameters().getAuthorizations()); case EDGE: return (Iterable<T>) getGraph().getEdges(fetchHints, getParameters().getAuthorizations()); default: throw new VertexiumException("Unexpected element type: " + elementType); } }
@Override protected QueryResultsIterable<? extends VertexiumObject> extendedData(FetchHints fetchHints) { Iterable<Vertex> vertices = getGraph().getVertices(IterableUtils.toIterable(getVertexIds()), fetchHints, getParameters().getAuthorizations()); Iterable<String> edgeIds = new VerticesToEdgeIdsIterable(vertices, getParameters().getAuthorizations()); Iterable<Edge> edges = getGraph().getEdges(edgeIds, fetchHints, getParameters().getAuthorizations()); return extendedData(fetchHints, new JoinIterable<>(vertices, edges)); }
@Override public QueryResultsIterable<Edge> edges(FetchHints fetchHints) { Iterable<Vertex> vertices = getGraph().getVertices(IterableUtils.toIterable(getVertexIds()), fetchHints, getParameters().getAuthorizations()); Iterable<String> edgeIds = new VerticesToEdgeIdsIterable(vertices, getParameters().getAuthorizations()); Iterable<Edge> edges = getGraph().getEdges(edgeIds, fetchHints, getParameters().getAuthorizations()); return new DefaultGraphQueryIterableWithAggregations<>(getParameters(), edges, true, true, true, getAggregations()); }
@Override protected QueryResultsIterable<? extends VertexiumObject> extendedData(FetchHints fetchHints) { Iterable<Vertex> vertices = getGraph().getVertices(IterableUtils.toIterable(getVertexIds()), fetchHints, getParameters().getAuthorizations()); Iterable<String> edgeIds = new VerticesToEdgeIdsIterable(vertices, getParameters().getAuthorizations()); Iterable<Edge> edges = getGraph().getEdges(edgeIds, fetchHints, getParameters().getAuthorizations()); return extendedData(fetchHints, new JoinIterable<>(vertices, edges)); }
protected String[] getPropertyNames(String propertyName) { return getSearchIndex().getAllMatchingPropertyNames(getGraph(), propertyName, getParameters().getAuthorizations()); }
protected String[] getPropertyNames(String propertyName) { return getSearchIndex().getAllMatchingPropertyNames(getGraph(), propertyName, getParameters().getAuthorizations()); }
protected String[] getPropertyNames(String propertyName) { return getSearchIndex().getPropertyNames(getGraph(), propertyName, getParameters().getAuthorizations()); }
@Override public QueryResultsIterable<Edge> edges(FetchHints fetchHints) { Iterable<Vertex> vertices = getGraph().getVertices(IterableUtils.toIterable(getVertexIds()), fetchHints, getParameters().getAuthorizations()); Iterable<String> edgeIds = new VerticesToEdgeIdsIterable(vertices, getParameters().getAuthorizations()); Iterable<Edge> edges = getGraph().getEdges(edgeIds, fetchHints, getParameters().getAuthorizations()); return new DefaultGraphQueryIterableWithAggregations<>(getParameters(), edges, true, true, true, getAggregations()); }
protected String[] getPropertyNames(String propertyName) { return getSearchIndex().getPropertyNames(getGraph(), propertyName, getParameters().getAuthorizations()); }
private Iterable<Edge> allEdges(FetchHints fetchHints) { Iterable<Edge> results = getSourceVertex().getEdges(getDirection(), fetchHints, getParameters().getAuthorizations()); if (getOtherVertexId() != null) { results = new FilterIterable<Edge>(results) { @Override protected boolean isIncluded(Edge edge) { return edge.getOtherVertexId(getSourceVertex().getId()).equals(getOtherVertexId()); } }; } return results; }
private Iterable<Edge> allEdges(FetchHints fetchHints) { Iterable<Edge> results = getSourceVertex().getEdges(getDirection(), fetchHints, getParameters().getAuthorizations()); if (getOtherVertexId() != null) { results = new FilterIterable<Edge>(results) { @Override protected boolean isIncluded(Edge edge) { return edge.getOtherVertexId(getSourceVertex().getId()).equals(getOtherVertexId()); } }; } return results; }
protected QueryBuilder createQueryStringQuery(QueryStringQueryParameters queryParameters) { String queryString = queryParameters.getQueryString(); if (queryString == null || queryString.equals("*")) { return QueryBuilders.matchAllQuery(); } ElasticsearchSingleDocumentSearchIndex es = (ElasticsearchSingleDocumentSearchIndex) ((GraphWithSearchIndex) getGraph()).getSearchIndex(); if (es.isServerPluginInstalled()) { return VertexiumQueryStringQueryBuilder.build(queryString, getParameters().getAuthorizations()); } else { Collection<String> fields = es.getQueryablePropertyNames(getGraph(), getParameters().getAuthorizations()); QueryStringQueryBuilder qs = QueryBuilders.queryStringQuery(queryString); for (String field : fields) { qs = qs.field(field); } return qs; } }
protected QueryBuilder createQueryStringQuery(QueryStringQueryParameters queryParameters) { String queryString = queryParameters.getQueryString(); if (queryString == null || queryString.equals("*")) { return QueryBuilders.matchAllQuery(); } Elasticsearch2SearchIndex es = (Elasticsearch2SearchIndex) ((GraphWithSearchIndex) getGraph()).getSearchIndex(); if (es.isServerPluginInstalled()) { return VertexiumQueryStringQueryBuilder.build(queryString, getParameters().getAuthorizations()); } else { Collection<String> fields = es.getQueryablePropertyNames(getGraph(), getParameters().getAuthorizations()); QueryStringQueryBuilder qs = QueryBuilders.queryStringQuery(queryString); for (String field : fields) { qs = qs.field(field); } return qs; } }
protected QueryBuilder createQueryStringQuery(QueryStringQueryParameters queryParameters) { String queryString = queryParameters.getQueryString(); if (queryString == null || queryString.equals("*")) { return QueryBuilders.matchAllQuery(); } if (getSearchIndex().isServerPluginInstalled()) { return VertexiumQueryStringQueryBuilder.build(queryString, getParameters().getAuthorizations()); } else { Collection<String> fields = getSearchIndex().getQueryablePropertyNames(getGraph(), getParameters().getAuthorizations()); QueryStringQueryBuilder qs = QueryBuilders.queryStringQuery(queryString); for (String field : fields) { qs = qs.field(getSearchIndex().replaceFieldnameDots(field)); } qs.allowLeadingWildcard(false); return qs; } }
protected QueryBuilder createQueryStringQuery(QueryStringQueryParameters queryParameters) { String queryString = queryParameters.getQueryString(); if (queryString == null || queryString.equals("*")) { return QueryBuilders.matchAllQuery(); } if (getSearchIndex().isServerPluginInstalled()) { return VertexiumQueryStringQueryBuilder.build(queryString, getParameters().getAuthorizations()); } else { Collection<String> fields = getSearchIndex().getQueryablePropertyNames(getGraph(), getParameters().getAuthorizations()); QueryStringQueryBuilder qs = QueryBuilders.queryStringQuery(queryString); for (String field : fields) { qs = qs.field(getSearchIndex().replaceFieldnameDots(field)); } qs.allowLeadingWildcard(false); return qs; } }
@Override public QueryResultsIterable<Vertex> vertices(FetchHints fetchHints) { Iterable<Vertex> vertices = getGraph().getVertices(IterableUtils.toIterable(getVertexIds()), fetchHints, getParameters().getAuthorizations()); return new DefaultGraphQueryIterableWithAggregations<>(getParameters(), vertices, true, true, true, getAggregations()); }
@Override public QueryResultsIterable<Vertex> vertices(FetchHints fetchHints) { Iterable<Vertex> vertices = getGraph().getVertices(IterableUtils.toIterable(getVertexIds()), fetchHints, getParameters().getAuthorizations()); return new DefaultGraphQueryIterableWithAggregations<>(getParameters(), vertices, true, true, true, getAggregations()); }