ElasticSearch NEST 2.4 Does Percolator Exist


(Chris Ford) #1

Hi All,

Is there anyway in NEST 2.4 to determine whether a percolator type exists, or get a count of the number of documents registered with the percolator?

I am building a service that if the percolator type doesn't exist then it will build up the percolator, however I do not want to run this every time for obvious reasons. Ideally I would like to compare the count of percolated queries against the expected amount, but otherwise I will just go with whether the type exists.

I have tried using the TypeExists method within the ElasticClient however this returns false, even though the .percolator type does exist and I can happily get documents from the percolator later on.

Any help would be great.

Thanks

Chris


(Russ Cam) #2

You can check if a query document exists for percolation using .DocumentExists<T>() or .DocumentExistsAsync<T>()

var documentExistsResponse = this.Client.DocumentExists<object>("document-id", d => d
    .Index("index-name")
    .Type(".percolator")
);

if (documentExistsResponse.Exists)
{
    // document exists
}

This method can be used to check for the existence of any document type in an index.


(Chris Ford) #3

Excellent, thanks for the help, that worked perfectly.


(system) #4

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