use of org.elasticsearch.index.query.QueryBuilder in project graylog2-server by Graylog2.
the class Searches method standardSearchRequest.
private SearchRequestBuilder standardSearchRequest(String query, Set<String> indices, int limit, int offset, TimeRange range, String filter, Sorting sort, boolean highlight) {
if (query == null || query.trim().isEmpty()) {
query = "*";
}
final QueryBuilder queryBuilder;
if ("*".equals(query.trim())) {
queryBuilder = matchAllQuery();
} else {
queryBuilder = queryStringQuery(query).allowLeadingWildcard(configuration.isAllowLeadingWildcardSearches());
}
final SearchRequestBuilder srb = c.prepareSearch(indices.toArray(new String[indices.size()])).setIndicesOptions(IndicesOptions.lenientExpandOpen()).setQuery(QueryBuilders.boolQuery().must(queryBuilder).filter(standardFilters(range, filter))).setFrom(offset);
if (limit > 0) {
srb.setSize(limit);
}
if (sort != null) {
srb.addSort(sort.getField(), sort.asElastic());
}
if (highlight && configuration.isAllowHighlighting()) {
srb.setHighlighterRequireFieldMatch(false);
srb.addHighlightedField("*", 0, 0);
}
return srb;
}
use of org.elasticsearch.index.query.QueryBuilder in project fess by codelibs.
the class AdminSearchlistAction method delete.
// -----------------------------------------------------
// Confirm
// -------
@Execute
public HtmlResponse delete(final DeleteForm form) {
validate(form, messages -> {
}, () -> asListHtml());
verifyToken(() -> asListHtml());
final String docId = form.docId;
try {
final QueryBuilder query = QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), docId);
fessEsClient.deleteByQuery(fessConfig.getIndexDocumentUpdateIndex(), fessConfig.getIndexDocumentType(), query);
saveInfo(messages -> messages.addSuccessDeleteDocFromIndex(GLOBAL));
} catch (final Exception e) {
throwValidationError(messages -> messages.addErrorsFailedToDeleteDocInAdmin(GLOBAL), () -> asListHtml());
}
return asListHtml();
}
use of org.elasticsearch.index.query.QueryBuilder in project fess by codelibs.
the class BsBoostDocumentRuleCB method build.
// ===================================================================================
// Build
// =====
@Override
public SearchRequestBuilder build(SearchRequestBuilder builder) {
if (_conditionQuery != null) {
QueryBuilder queryBuilder = _conditionQuery.getQuery();
if (queryBuilder != null) {
builder.setQuery(queryBuilder);
}
_conditionQuery.getFieldSortBuilderList().forEach(sort -> {
builder.addSort(sort);
});
}
if (_conditionAggregation != null) {
_conditionAggregation.getAggregationBuilderList().forEach(builder::addAggregation);
}
if (_specification != null) {
builder.setFetchSource(_specification.columnList.toArray(new String[_specification.columnList.size()]), null);
}
return builder;
}
use of org.elasticsearch.index.query.QueryBuilder in project fess by codelibs.
the class BsLabelToRoleCB method build.
// ===================================================================================
// Build
// =====
@Override
public SearchRequestBuilder build(SearchRequestBuilder builder) {
if (_conditionQuery != null) {
QueryBuilder queryBuilder = _conditionQuery.getQuery();
if (queryBuilder != null) {
builder.setQuery(queryBuilder);
}
_conditionQuery.getFieldSortBuilderList().forEach(sort -> {
builder.addSort(sort);
});
}
if (_conditionAggregation != null) {
_conditionAggregation.getAggregationBuilderList().forEach(builder::addAggregation);
}
if (_specification != null) {
builder.setFetchSource(_specification.columnList.toArray(new String[_specification.columnList.size()]), null);
}
return builder;
}
use of org.elasticsearch.index.query.QueryBuilder in project fess by codelibs.
the class BsPathMappingCB method build.
// ===================================================================================
// Build
// =====
@Override
public SearchRequestBuilder build(SearchRequestBuilder builder) {
if (_conditionQuery != null) {
QueryBuilder queryBuilder = _conditionQuery.getQuery();
if (queryBuilder != null) {
builder.setQuery(queryBuilder);
}
_conditionQuery.getFieldSortBuilderList().forEach(sort -> {
builder.addSort(sort);
});
}
if (_conditionAggregation != null) {
_conditionAggregation.getAggregationBuilderList().forEach(builder::addAggregation);
}
if (_specification != null) {
builder.setFetchSource(_specification.columnList.toArray(new String[_specification.columnList.size()]), null);
}
return builder;
}
Aggregations