0

I'm using ES version 1.5.2, and making use of the JAVA APIs via JEST wrapper. I would like to create some percolate queries and store them in the index.

In some places, I see a syntax which suggests I can store percolate queries in any index, but the type has to be of type '.percolator'. In other places, I've seen that the queries need to be stored in a special index called '_percolator'.

  • Where should percolate queries be stored?
  • Should the queries be saved in the index like a regular document is?

Below is a snippet of code which i tried, but it doesn't work.

SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchQuery("stock", "apple"));
saveDoc(searchSourceBuilder, "company-apple", "_percolator", "stocks");

public JestResult saveDoc(Object doc, String docId, String indexName, String type) {
    Index index = new Index.Builder(doc).id(docId).index(indexName).type(type).build();
    return client.execute(index);
}
Nkosi
  • 235,767
  • 35
  • 427
  • 472
Raunak
  • 6,427
  • 9
  • 40
  • 52

1 Answers1

0

Calling .toString() explicitly on searchSourceBuilder fixes the problem. Not sure why this has to be done; I would have imagined that GSON would have done this later on in the JEST library.

Raunak
  • 6,427
  • 9
  • 40
  • 52