Search in sources :

Example 31 with QueryBuilder

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;
}
Also used : QueryBuilder(org.opensearch.index.query.QueryBuilder)

Example 32 with QueryBuilder

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());
}
Also used : PrefixQueryBuilder(org.opensearch.index.query.PrefixQueryBuilder) QueryBuilder(org.opensearch.index.query.QueryBuilder) MatchPhraseQueryBuilder(org.opensearch.index.query.MatchPhraseQueryBuilder) BoolQueryBuilder(org.opensearch.index.query.BoolQueryBuilder)

Example 33 with QueryBuilder

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());
}
Also used : Constants(org.codelibs.fess.Constants) AdminSearchlistAction.getDoc(org.codelibs.fess.app.web.admin.searchlist.AdminSearchlistAction.getDoc) SearchEngineClient(org.codelibs.fess.es.client.SearchEngineClient) ApiDeleteResponse(org.codelibs.fess.app.web.api.ApiResult.ApiDeleteResponse) ResultOffsetExceededException(org.codelibs.fess.exception.ResultOffsetExceededException) AdminSearchlistAction.validateFields(org.codelibs.fess.app.web.admin.searchlist.AdminSearchlistAction.validateFields) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Status(org.codelibs.fess.app.web.api.ApiResult.Status) CrudMode(org.codelibs.fess.app.web.CrudMode) Map(java.util.Map) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) SearchHelper(org.codelibs.fess.helper.SearchHelper) SearchRenderData(org.codelibs.fess.entity.SearchRenderData) QueryBuilders(org.opensearch.index.query.QueryBuilders) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) ApiDocResponse(org.codelibs.fess.app.web.api.ApiResult.ApiDocResponse) Resource(javax.annotation.Resource) StringUtil(org.codelibs.core.lang.StringUtil) JsonResponse(org.lastaflute.web.response.JsonResponse) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Logger(org.apache.logging.log4j.Logger) QueryBuilder(org.opensearch.index.query.QueryBuilder) ComponentUtil(org.codelibs.fess.util.ComponentUtil) ApiDocsResponse(org.codelibs.fess.app.web.api.ApiResult.ApiDocsResponse) Execute(org.lastaflute.web.Execute) InvalidQueryException(org.codelibs.fess.exception.InvalidQueryException) LogManager(org.apache.logging.log4j.LogManager) QueryBuilder(org.opensearch.index.query.QueryBuilder) ResultOffsetExceededException(org.codelibs.fess.exception.ResultOffsetExceededException) InvalidQueryException(org.codelibs.fess.exception.InvalidQueryException) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) Execute(org.lastaflute.web.Execute)

Example 34 with QueryBuilder

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();
}
Also used : SearchEngineClient(org.codelibs.fess.es.client.SearchEngineClient) QueryBuilder(org.opensearch.index.query.QueryBuilder) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Example 35 with QueryBuilder

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;
}
Also used : QueryBuilder(org.opensearch.index.query.QueryBuilder)

Aggregations

QueryBuilder (org.opensearch.index.query.QueryBuilder)47 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)11 SearchEngineClient (org.codelibs.fess.es.client.SearchEngineClient)6 BoolQueryBuilder (org.opensearch.index.query.BoolQueryBuilder)6 Map (java.util.Map)5 LogManager (org.apache.logging.log4j.LogManager)4 Logger (org.apache.logging.log4j.Logger)4 StringUtil (org.codelibs.core.lang.StringUtil)4 Constants (org.codelibs.fess.Constants)4 MatchPhraseQueryBuilder (org.opensearch.index.query.MatchPhraseQueryBuilder)4 PrefixQueryBuilder (org.opensearch.index.query.PrefixQueryBuilder)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Resource (javax.annotation.Resource)3 ComponentUtil (org.codelibs.fess.util.ComponentUtil)3 QueryBuilders (org.opensearch.index.query.QueryBuilders)3 HashMap (java.util.HashMap)2 Consumer (java.util.function.Consumer)2 PostConstruct (javax.annotation.PostConstruct)2 Tuple3 (org.codelibs.core.misc.Tuple3)2