use of org.opensearch.index.query.QueryBuilder in project fess by codelibs.
the class BsUserInfoCB 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.opensearch.index.query.QueryBuilder in project fess by codelibs.
the class QueryHelperTest method assertQueryBuilder.
private void assertQueryBuilder(String field, String value, Class<?> clazz) {
QueryBuilder queryBuilder = queryHelper.buildMatchPhraseQuery(field, value);
assertEquals(clazz, queryBuilder.getClass());
}
use of org.opensearch.index.query.QueryBuilder in project fess by codelibs.
the class ApiAdminSearchlistAction method delete$doc.
// DELETE /api/admin/searchlist/doc/{doc_id}
@Execute
public JsonResponse<ApiResult> delete$doc(final String id) {
try {
final QueryBuilder query = QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), id);
searchEngineClient.deleteByQuery(fessConfig.getIndexDocumentUpdateIndex(), query);
saveInfo(messages -> messages.addSuccessDeleteDocFromIndex(GLOBAL));
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsFailedToDeleteDocInAdmin(GLOBAL));
}
return asJson(new ApiResponse().status(Status.OK).result());
}
use of org.opensearch.index.query.QueryBuilder in project fess by codelibs.
the class PurgeDocJob method execute.
public String execute() {
final SearchEngineClient searchEngineClient = ComponentUtil.getSearchEngineClient();
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final StringBuilder resultBuf = new StringBuilder();
// clean up
final QueryBuilder queryBuilder = QueryBuilders.rangeQuery(fessConfig.getIndexFieldExpires()).to("now");
try {
searchEngineClient.deleteByQuery(fessConfig.getIndexDocumentUpdateIndex(), queryBuilder);
} catch (final Exception e) {
logger.error("Could not delete expired documents: {}", queryBuilder.toString(), e);
resultBuf.append(e.getMessage()).append("\n");
}
return resultBuf.toString();
}
use of org.opensearch.index.query.QueryBuilder in project fess by codelibs.
the class BsBadWordCB 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