Search in sources :

Example 1 with AnalyzeRequest

use of org.elasticsearch.client.indices.AnalyzeRequest in project LinkAgent by shulieTech.

the class AnalyzeRequestIndexRename0 method reindex0.

@Override
public List<String> reindex0(Object target) {
    AnalyzeRequest req = (AnalyzeRequest) target;
    String index = req.index();
    /**
     * 如果在白名单中则不允许写
     */
    if (GlobalConfig.getInstance().getSearchWhiteList().contains(index)) {
        return Arrays.asList(index);
    }
    if (!Pradar.isClusterTestPrefix(index)) {
        index = Pradar.addClusterTestPrefixLower(index);
    }
    try {
        Reflect.on(req).set("index", index);
    } catch (ReflectException e) {
        throw new PressureMeasureError("can't found field index from " + AnalyzeRequest.class.getName());
    }
    return Arrays.asList(index);
}
Also used : PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) AnalyzeRequest(org.elasticsearch.client.indices.AnalyzeRequest) ReflectException(com.shulie.instrument.simulator.api.reflect.ReflectException)

Example 2 with AnalyzeRequest

use of org.elasticsearch.client.indices.AnalyzeRequest in project spring-data-elasticsearch by spring-projects.

the class RequestConverters method analyze.

public static Request analyze(AnalyzeRequest request) {
    EndpointBuilder builder = new EndpointBuilder();
    String index = request.index();
    if (index != null) {
        builder.addPathPart(index);
    }
    builder.addPathPartAsIs("_analyze");
    Request req = new Request(HttpMethod.GET.name(), builder.build());
    req.setEntity(createEntity(request, REQUEST_BODY_CONTENT_TYPE));
    return req;
}
Also used : ExplainRequest(org.elasticsearch.action.explain.ExplainRequest) GetMappingsRequest(org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest) SearchTemplateRequest(org.elasticsearch.script.mustache.SearchTemplateRequest) DeleteRequest(org.elasticsearch.action.delete.DeleteRequest) IndexRequest(org.elasticsearch.action.index.IndexRequest) DeleteByQueryRequest(org.elasticsearch.index.reindex.DeleteByQueryRequest) FieldCapabilitiesRequest(org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest) CountRequest(org.elasticsearch.client.core.CountRequest) IndexTemplatesExistRequest(org.elasticsearch.client.indices.IndexTemplatesExistRequest) GetStoredScriptRequest(org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest) GetRequest(org.elasticsearch.action.get.GetRequest) RankEvalRequest(org.elasticsearch.index.rankeval.RankEvalRequest) GetAliasesRequest(org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest) IndicesAliasesRequest(org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest) AbstractBulkByScrollRequest(org.elasticsearch.index.reindex.AbstractBulkByScrollRequest) DeleteIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest) ClusterHealthRequest(org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest) GetSettingsRequest(org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest) PutStoredScriptRequest(org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest) ClearScrollRequest(org.elasticsearch.action.search.ClearScrollRequest) PutIndexTemplateRequest(org.elasticsearch.client.indices.PutIndexTemplateRequest) DeleteStoredScriptRequest(org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest) MultiGetRequest(org.elasticsearch.action.get.MultiGetRequest) SearchRequest(org.elasticsearch.action.search.SearchRequest) OpenIndexRequest(org.elasticsearch.action.admin.indices.open.OpenIndexRequest) MultiSearchRequest(org.elasticsearch.action.search.MultiSearchRequest) CreateIndexRequest(org.elasticsearch.action.admin.indices.create.CreateIndexRequest) RefreshRequest(org.elasticsearch.action.admin.indices.refresh.RefreshRequest) UpdateByQueryRequest(org.elasticsearch.index.reindex.UpdateByQueryRequest) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) GetIndexRequest(org.elasticsearch.action.admin.indices.get.GetIndexRequest) GetIndexTemplatesRequest(org.elasticsearch.client.indices.GetIndexTemplatesRequest) GetFieldMappingsRequest(org.elasticsearch.client.indices.GetFieldMappingsRequest) UpdateRequest(org.elasticsearch.action.update.UpdateRequest) DocWriteRequest(org.elasticsearch.action.DocWriteRequest) Request(org.elasticsearch.client.Request) AnalyzeRequest(org.elasticsearch.client.indices.AnalyzeRequest) CloseIndexRequest(org.elasticsearch.action.admin.indices.close.CloseIndexRequest) RethrottleRequest(org.elasticsearch.client.RethrottleRequest) FlushRequest(org.elasticsearch.action.admin.indices.flush.FlushRequest) PutMappingRequest(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest) SearchScrollRequest(org.elasticsearch.action.search.SearchScrollRequest) BulkRequest(org.elasticsearch.action.bulk.BulkRequest) ReindexRequest(org.elasticsearch.index.reindex.ReindexRequest)

Example 3 with AnalyzeRequest

use of org.elasticsearch.client.indices.AnalyzeRequest in project kms by mahonelau.

the class EsUtils method getIkAnalyzeSearchTerms.

public List<String> getIkAnalyzeSearchTerms(String searchContent) {
    AnalyzeRequest analyzeRequest = AnalyzeRequest.withIndexAnalyzer(KMConstant.DocIndexAliasName, "ik_smart", searchContent);
    List<String> result = new ArrayList<>();
    try {
        if (!searchContent.isEmpty()) {
            AnalyzeResponse analyzeResponse = restHighLevelClient.indices().analyze(analyzeRequest, RequestOptions.DEFAULT);
            analyzeResponse.getTokens().forEach((e) -> result.add(e.getTerm()));
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) AnalyzeRequest(org.elasticsearch.client.indices.AnalyzeRequest) IOException(java.io.IOException) AnalyzeResponse(org.elasticsearch.client.indices.AnalyzeResponse)

Example 4 with AnalyzeRequest

use of org.elasticsearch.client.indices.AnalyzeRequest in project dsearch-server by danawalab.

the class RankingTuningService method getMultipleAnalyze.

public AnalyzeResponse getMultipleAnalyze(UUID clusterId, String index, String analyzer, String hitValue) throws IOException {
    try (RestHighLevelClient client = elasticsearchFactory.getClient(clusterId)) {
        AnalyzeRequest analyzeRequest = AnalyzeRequest.withIndexAnalyzer(index, analyzer, hitValue);
        AnalyzeResponse analyzeResponse = client.indices().analyze(analyzeRequest, RequestOptions.DEFAULT);
        return analyzeResponse;
    }
}
Also used : AnalyzeRequest(org.elasticsearch.client.indices.AnalyzeRequest) AnalyzeResponse(org.elasticsearch.client.indices.AnalyzeResponse)

Example 5 with AnalyzeRequest

use of org.elasticsearch.client.indices.AnalyzeRequest in project dsearch-server by danawalab.

the class RankingTuningService method getAnalyze.

public AnalyzeResponse getAnalyze(UUID clusterId, RankingTuningRequest rankingTuningRequest, String analyzer, String hitValue) throws IOException {
    try (RestHighLevelClient client = elasticsearchFactory.getClient(clusterId)) {
        AnalyzeRequest analyzeRequest = AnalyzeRequest.withIndexAnalyzer(rankingTuningRequest.getIndex(), analyzer, hitValue);
        AnalyzeResponse analyzeResponse = client.indices().analyze(analyzeRequest, RequestOptions.DEFAULT);
        return analyzeResponse;
    }
}
Also used : AnalyzeRequest(org.elasticsearch.client.indices.AnalyzeRequest) AnalyzeResponse(org.elasticsearch.client.indices.AnalyzeResponse)

Aggregations

AnalyzeRequest (org.elasticsearch.client.indices.AnalyzeRequest)7 AnalyzeResponse (org.elasticsearch.client.indices.AnalyzeResponse)5 ArrayList (java.util.ArrayList)2 PressureMeasureError (com.pamirs.pradar.exception.PressureMeasureError)1 ReflectException (com.shulie.instrument.simulator.api.reflect.ReflectException)1 IOException (java.io.IOException)1 IkAnalyzeVO (net.renfei.model.kitbox.IkAnalyzeVO)1 DocWriteRequest (org.elasticsearch.action.DocWriteRequest)1 ClusterHealthRequest (org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest)1 DeleteStoredScriptRequest (org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest)1 GetStoredScriptRequest (org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest)1 PutStoredScriptRequest (org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest)1 IndicesAliasesRequest (org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest)1 GetAliasesRequest (org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest)1 CloseIndexRequest (org.elasticsearch.action.admin.indices.close.CloseIndexRequest)1 CreateIndexRequest (org.elasticsearch.action.admin.indices.create.CreateIndexRequest)1 DeleteIndexRequest (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)1 FlushRequest (org.elasticsearch.action.admin.indices.flush.FlushRequest)1 GetIndexRequest (org.elasticsearch.action.admin.indices.get.GetIndexRequest)1 GetMappingsRequest (org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest)1