use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project vertigo by KleeGroup.
the class ESSearchRequestBuilder method appendSearchQuery.
private static QueryBuilder appendSearchQuery(final SearchQuery searchQuery, final BoolQueryBuilder filterBoolQueryBuilder) {
final QueryBuilder queryBuilder = translateToQueryBuilder(searchQuery.getListFilter());
filterBoolQueryBuilder.must(queryBuilder);
return queryBuilder;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project vertigo by KleeGroup.
the class ESSearchRequestBuilder method appendSearchQuery.
private static void appendSearchQuery(final SearchQuery searchQuery, final SearchRequestBuilder searchRequestBuilder, final boolean useHighlight) {
final BoolQueryBuilder filterBoolQueryBuilder = QueryBuilders.boolQuery();
final BoolQueryBuilder postFilterBoolQueryBuilder = QueryBuilders.boolQuery();
// on ajoute les critères de la recherche AVEC impact sur le score
final QueryBuilder queryBuilder = appendSearchQuery(searchQuery, filterBoolQueryBuilder);
// on ajoute les filtres de sécurité SANS impact sur le score
appendSecurityFilter(searchQuery.getSecurityListFilter(), filterBoolQueryBuilder);
// on ajoute les filtres des facettes SANS impact sur le score
appendSelectedFacetValues(searchQuery.getFacetedQuery(), filterBoolQueryBuilder, postFilterBoolQueryBuilder);
final QueryBuilder requestQueryBuilder;
if (searchQuery.isBoostMostRecent()) {
requestQueryBuilder = appendBoostMostRecent(searchQuery, queryBuilder);
} else {
requestQueryBuilder = filterBoolQueryBuilder;
}
searchRequestBuilder.setQuery(requestQueryBuilder).setPostFilter(postFilterBoolQueryBuilder);
if (useHighlight) {
// .setHighlighterFilter(true) //We don't highlight the security filter
// .addHighlightedField("*"); HOW TO ?
searchRequestBuilder.highlighter(new HighlightBuilder().numOfFragments(3));
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project vertigo by KleeGroup.
the class ESSearchRequestBuilder method appendSecurityFilter.
private static void appendSecurityFilter(final Optional<ListFilter> securityListFilter, final BoolQueryBuilder filterBoolQueryBuilder) {
if (securityListFilter.isPresent()) {
final QueryBuilder securityFilterBuilder = translateToQueryBuilder(securityListFilter.get());
filterBoolQueryBuilder.filter(securityFilterBuilder);
// use filteredQuery instead of PostFilter in order to filter aggregations too.
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project vertexium by visallo.
the class ElasticsearchSearchVertexQuery method getEdgeFilter.
private QueryBuilder getEdgeFilter() {
switch(direction) {
case BOTH:
QueryBuilder inVertexIdFilter = getDirectionInEdgeFilter();
QueryBuilder outVertexIdFilter = getDirectionOutEdgeFilter();
return QueryBuilders.boolQuery().should(inVertexIdFilter).should(outVertexIdFilter).minimumShouldMatch(1);
case OUT:
return getDirectionOutEdgeFilter();
case IN:
return getDirectionInEdgeFilter();
default:
throw new VertexiumException("unexpected direction: " + direction);
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project vertexium by visallo.
the class Elasticsearch5SearchIndex method deleteExtendedDataForElement.
private void deleteExtendedDataForElement(Element element) {
try {
QueryBuilder filter = QueryBuilders.termQuery(ELEMENT_ID_FIELD_NAME, element.getId());
SearchRequestBuilder s = getClient().prepareSearch(getIndicesToQuery()).setTypes(getIdStrategy().getType()).setQuery(QueryBuilders.boolQuery().must(QueryBuilders.matchAllQuery()).filter(filter)).storedFields(ELEMENT_ID_FIELD_NAME, EXTENDED_DATA_TABLE_NAME_FIELD_NAME, EXTENDED_DATA_TABLE_ROW_ID_FIELD_NAME);
SearchResponse searchResponse = checkForFailures(s.execute().get());
for (SearchHit hit : searchResponse.getHits()) {
if (MUTATION_LOGGER.isTraceEnabled()) {
LOGGER.trace("deleting extended data document %s", hit.getId());
}
getIndexRefreshTracker().pushChange(hit.getIndex());
getClient().prepareDelete(hit.getIndex(), hit.getType(), hit.getId()).execute().actionGet();
}
} catch (Exception ex) {
throw new VertexiumException("Could not delete extended data for element: " + element.getId());
}
}
Aggregations