Elasticsearch How to exclude indices when using Java Api Client

  Kiến thức lập trình

Elk-Stack Version: 8.7.1
Java Api Client: 8.13.1

When executing a search I want to search over all indices excluding all indices that start with a dot.
According to the regular Elasticsearch Api you put *,-.* in the path.

When I use the withJson functionality of the Java Api Client I dont have the possibility to define the path with indices, I have just the index-Method.

So how can I exclude these indices ?

Reader queryJson = new StringReader("{n" +
                    "  "_source": {n" +
                    "    "excludes": [ "@timestamp", "@version" ]n" +
                    "  },n" +
                    "  "size": 500,n" +
                    "  "query": {n" +
                    "    "multi_match": {n" +
                    "      "query": "Beratung",n" +
                    "      "fields": ["*"]n" +
                    "    }n" +
                    "  }n" +
                    "}");

            SearchRequest request = SearchRequest.of(b -> b.withJson(queryJson).index("_all"));
            SearchResponse<Object> response = esClient.search(request, Object.class);

I tried passing ““, “-.” to the index method without success.

LEAVE A COMMENT