No support for PercolateQueryBuilder in High Level Rest

I cannot find support for the Percolator query in the HighLevelrest client. Is there a reason for that? Or am I missing something?

I created a WrapperQuery with the the percolator query as a string. But would like to have the PercolateQueryBuilder as well.

Thanks,
Jettro

Hey Jettro,

IIRC the PercolateQueryBuilder is in the percolator module and not part of the main dependency.

--Alex

HI Alex, I'm trying to migrate the old Transport Client to the new High Level REST Client and I cannot find a way to migrate the percolator code. I Currently use the PercolateQueryBuilder and cannot find any references to the percolate module you mentioned above. Neither any documentation on the elastic website. Can you point me in the right direction please?

Thanks!

Javier C

I ended up using the XContentBuilder, maybe it can help you:

    String source = "{\n" +
            "    \"person\" : {\n" +
            "        \"match_phrase\" : {\n" +
            "            \"message\" : {\n" +
            "              \"query\": \"" + person.getName() + "\",\n" +
            "              \"slop\": 2\n" +
            "            }\n        }\n" +
            "    },\n" +
            "    \"role\": \"" + person.getRole() + "\",\n" +
            "    \"name\": \"" + person.getName() + "\",\n" +
            "    \"times_sold\": " + person.getTimesSold() + "\n" +
            "}";
    IndexRequest indexRequest = new IndexRequest(INDEX_NAME).source(source, XContentType.JSON);

and the query:

SearchSourceBuilder builder = new SearchSourceBuilder();

WrapperQueryBuilder wrapperQueryBuilder = QueryBuilders.wrapperQuery("{\n" +
        "    \"percolate\": {\n" +
        "      \"field\": \"person\",\n" +
        "      \"document\": {\n" +
        "        \"message\": \"" + text + "\"\n" +
        "      }\n" +
        "    }\n" +
        "  }");
builder.query(wrapperQueryBuilder);
SearchRequest searchRequest = new SearchRequest(ElasticInitialiser.INDEX_NAME);
searchRequest.source(builder);
1 Like

Thank you Jettro, this really helped!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.