Search in sources :

Example 1 with PredicatesHolder

use of org.unipop.query.predicates.PredicatesHolder in project unipop by unipop-graph.

the class DocVertexSchema method getSearch.

@Override
public QueryBuilder getSearch(DeferredVertexQuery query) {
    PredicatesHolder predicatesHolder = this.toPredicates(query.getVertices());
    QueryBuilder queryBuilder = createQueryBuilder(predicatesHolder);
    return queryBuilder;
}
Also used : PredicatesHolder(org.unipop.query.predicates.PredicatesHolder) QueryBuilder(org.elasticsearch.index.query.QueryBuilder)

Example 2 with PredicatesHolder

use of org.unipop.query.predicates.PredicatesHolder in project unipop by unipop-graph.

the class NestedEdgeSchema method createQueryBuilder.

public QueryBuilder createQueryBuilder(SearchVertexQuery query) {
    PredicatesHolder edgePredicates = this.toPredicates(query.getPredicates());
    if (edgePredicates.isAborted())
        return null;
    PredicatesHolder childPredicates = childVertexSchema.toPredicates(query.getVertices());
    childPredicates = PredicatesHolderFactory.and(edgePredicates, childPredicates);
    QueryBuilder childQuery = createNestedQueryBuilder(childPredicates);
    if (query.getDirection().equals(parentDirection.opposite())) {
        if (childPredicates.isAborted())
            return null;
        return childQuery;
    } else if (!query.getDirection().equals(Direction.BOTH))
        childQuery = null;
    PredicatesHolder parentPredicates = parentVertexSchema.toPredicates(query.getVertices());
    QueryBuilder parentQuery = createQueryBuilder(parentPredicates);
    if (parentQuery != null) {
        // if (parentPredicates.isAborted()) return null;
        QueryBuilder edgeQuery = createNestedQueryBuilder(edgePredicates);
        if (edgeQuery != null) {
            parentQuery = QueryBuilders.boolQuery().must(parentQuery).must(edgeQuery);
        }
    }
    if (query.getDirection().equals(parentDirection) && parentPredicates.notAborted())
        return parentQuery;
    else if (childQuery == null && parentPredicates.notAborted())
        return parentQuery;
    else if (parentQuery == null && childPredicates.notAborted())
        return childQuery;
    else if (parentPredicates.isAborted() && childPredicates.isAborted())
        return null;
    else
        return QueryBuilders.boolQuery().should(parentQuery).should(childQuery);
}
Also used : PredicatesHolder(org.unipop.query.predicates.PredicatesHolder) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) NestedQueryBuilder(org.elasticsearch.index.query.NestedQueryBuilder)

Example 3 with PredicatesHolder

use of org.unipop.query.predicates.PredicatesHolder in project unipop by unipop-graph.

the class NestedVertexSchema method getSearch.

@Override
public QueryBuilder getSearch(DeferredVertexQuery query) {
    PredicatesHolder predicatesHolder = this.toPredicates(query.getVertices());
    QueryBuilder queryBuilder = createQueryBuilder(predicatesHolder);
    return queryBuilder;
}
Also used : PredicatesHolder(org.unipop.query.predicates.PredicatesHolder) QueryBuilder(org.elasticsearch.index.query.QueryBuilder)

Example 4 with PredicatesHolder

use of org.unipop.query.predicates.PredicatesHolder in project unipop by unipop-graph.

the class RowEdgeSchema method toPredicates.

@Override
public PredicatesHolder toPredicates(List<Vertex> vertices, Direction direction, PredicatesHolder predicates) {
    PredicatesHolder edgePredicates = this.toPredicates(predicates);
    PredicatesHolder vertexPredicates = this.getVertexPredicates(vertices, direction);
    return PredicatesHolderFactory.and(edgePredicates, vertexPredicates);
}
Also used : PredicatesHolder(org.unipop.query.predicates.PredicatesHolder)

Example 5 with PredicatesHolder

use of org.unipop.query.predicates.PredicatesHolder in project unipop by unipop-graph.

the class DocEdgeSchema method getSearch.

@Override
public QueryBuilder getSearch(SearchVertexQuery query) {
    PredicatesHolder edgePredicates = this.toPredicates(query.getPredicates());
    PredicatesHolder vertexPredicates = this.getVertexPredicates(query.getVertices(), query.getDirection());
    PredicatesHolder predicatesHolder = PredicatesHolderFactory.and(edgePredicates, vertexPredicates);
    if (predicatesHolder.isAborted())
        return null;
    QueryBuilder queryBuilder = createQueryBuilder(predicatesHolder);
    return queryBuilder;
// return createSearch(query, queryBuilder);
}
Also used : PredicatesHolder(org.unipop.query.predicates.PredicatesHolder) QueryBuilder(org.elasticsearch.index.query.QueryBuilder)

Aggregations

PredicatesHolder (org.unipop.query.predicates.PredicatesHolder)23 HasContainer (org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer)9 Collectors (java.util.stream.Collectors)7 java.util (java.util)6 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)6 Stream (java.util.stream.Stream)5 P (org.apache.tinkerpop.gremlin.process.traversal.P)5 JSONObject (org.json.JSONObject)5 PredicatesHolderFactory (org.unipop.query.predicates.PredicatesHolderFactory)4 SearchQuery (org.unipop.query.search.SearchQuery)4 AddVertexQuery (org.unipop.query.mutation.AddVertexQuery)3 ConversionUtils (org.unipop.util.ConversionUtils)3 Configuration (org.apache.commons.configuration.Configuration)2 StringUtils (org.apache.commons.lang3.StringUtils)2 GraphComputer (org.apache.tinkerpop.gremlin.process.computer.GraphComputer)2 TraversalStrategies (org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies)2 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)2 org.apache.tinkerpop.gremlin.structure (org.apache.tinkerpop.gremlin.structure)2 Element (org.apache.tinkerpop.gremlin.structure.Element)2 JSONArray (org.json.JSONArray)2