use of org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.QueryBuilder 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);
}
use of org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.QueryBuilder 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;
}
use of org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.QueryBuilder 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);
}
use of org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.QueryBuilder in project unipop by unipop-graph.
the class DocumentController method fetchProperties.
@Override
public void fetchProperties(DeferredVertexQuery uniQuery) {
Map<DocumentVertexSchema, QueryBuilder> schemas = vertexSchemas.stream().filter(schema -> this.traversalFilter.filter(schema, uniQuery.getTraversal())).collect(new SearchCollector<>((schema) -> schema.getSearch(uniQuery)));
Iterator<Vertex> search = search(uniQuery, schemas);
Map<Object, DeferredVertex> vertexMap = uniQuery.getVertices().stream().collect(Collectors.toMap(UniElement::id, Function.identity(), (a, b) -> a));
search.forEachRemaining(newVertex -> {
DeferredVertex deferredVertex = vertexMap.get(newVertex.id());
if (deferredVertex != null)
deferredVertex.loadProperties(newVertex);
});
}
use of org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.QueryBuilder in project syncope by apache.
the class ElasticsearchAnySearchDAO method fillAttrQuery.
private QueryBuilder fillAttrQuery(final PlainSchema schema, final PlainAttrValue attrValue, final AttributeCond cond) {
Object value = schema.getType() == AttrSchemaType.Date && attrValue.getDateValue() != null ? attrValue.getDateValue().getTime() : attrValue.getValue();
QueryBuilder builder = EMPTY_QUERY_BUILDER;
switch(cond.getType()) {
case ISNOTNULL:
builder = QueryBuilders.existsQuery(schema.getKey());
break;
case ISNULL:
builder = QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery(schema.getKey()));
break;
case ILIKE:
builder = QueryBuilders.queryStringQuery(schema.getKey() + ":" + cond.getExpression().replace('%', '*').toLowerCase());
break;
case LIKE:
builder = QueryBuilders.wildcardQuery(schema.getKey(), cond.getExpression().replace('%', '*'));
break;
case IEQ:
builder = QueryBuilders.matchQuery(schema.getKey(), cond.getExpression().toLowerCase());
break;
case EQ:
builder = QueryBuilders.termQuery(schema.getKey(), value);
break;
case GE:
builder = QueryBuilders.rangeQuery(schema.getKey()).gte(value);
break;
case GT:
builder = QueryBuilders.rangeQuery(schema.getKey()).gt(value);
break;
case LE:
builder = QueryBuilders.rangeQuery(schema.getKey()).lte(value);
break;
case LT:
builder = QueryBuilders.rangeQuery(schema.getKey()).lt(value);
break;
default:
}
return builder;
}
Aggregations