# Percolation when Indexing

**URL:** <https://discuss.elastic.co/t/percolation-when-indexing/19612>\
**Category:** Elasticsearch\
**Created:** [September 3, 2014, 10:54pm UTC](https://discuss.elastic.co/t/percolation-when-indexing/19612 "2014-09-03T22:54:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![IronMike](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@IronMike](https://discuss.elastic.co/u/IronMike)\
**Post date:** [September 3, 2014, 10:54pm UTC](https://discuss.elastic.co/t/percolation-when-indexing/19612/1 "2014-09-03T22:54:20Z")

</div>

My Java code isn't giving me percolation matches, but when I use the REST  
API after indexing is done, I can see there are percolation matches.  
My java pseudo code is showing below.  
My percolating code is right after I add a document to BulkProcessor for  
indexing. Percolation response never gets any results. What am I missing?

//createIndex ...

//Register Percolator  
QueryBuilder qb = QueryBuilders.matchQuery("content", "taxes");  
client.prepareIndex(index, ".percolator", "harkinQuery")  
.setSource(jsonBuilder()  
.startObject()  
.field("query", qb) // Register the query  
.endObject())  
.setRefresh(true) // Needed when the query shall be available immediately  
.execute().actionGet();

//index with BulkProcessor  
void addDocsToBulk(){  
for(i=0; i\< numDocs; i++)  
{  
JSONObject jDoc = getDoc[i];  
//add the doc to bulk processor

bulkProcessor.add(Requests.indexRequest(index).type(type).id(jDoc.  
getString("id")).source(jDoc.toString()));

//Percolate  
PercolateResponse response = client.preparePercolate()  
.setIndices("index")  
.setDocumentType("type")  
.setSource(jDoc.toString()).execute().actionGet();  
//Iterate over the results  
for(PercolateResponse.Match match : response) {  
//Handle the result which is the name of  
//the query in the percolator  
}

}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2952b537-6784-43ad-9642-df6652de4479%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2952b537-6784-43ad-9642-df6652de4479%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![IronMike](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@IronMike](https://discuss.elastic.co/u/IronMike)\
**Post date:** [September 4, 2014, 1:54pm UTC](https://discuss.elastic.co/t/percolation-when-indexing/19612/2 "2014-09-04T13:54:21Z")

</div>

Any ideas why the percolator isn't showing me matches while indexing in  
Transport java client, but shows fine after indexing process is done by  
REST query command like so:

GET /myIndex/type/1232/\_percolate  
"matches": [  
{  
"\_index": "myIndex",  
"\_id": "appealQuery"  
},  
{  
"\_index": "myIndex",  
"\_id": "harkinQuery"  
}

On Wednesday, September 3, 2014 6:54:20 PM UTC-4, IronMan2014 wrote:

> My Java code isn't giving me percolation matches, but when I use the REST  
> API after indexing is done, I can see there are percolation matches.  
> My java pseudo code is showing below.  
> My percolating code is right after I add a document to BulkProcessor for  
> indexing. Percolation response never gets any results. What am I missing?
> 
> //createIndex ...
> 
> //Register Percolator  
> QueryBuilder qb = QueryBuilders.matchQuery("content", "taxes");  
> client.prepareIndex(index, ".percolator", "harkinQuery")  
> .setSource(jsonBuilder()  
> .startObject()  
> .field("query", qb) // Register the query  
> .endObject())  
> .setRefresh(true) // Needed when the query shall be available immediately  
> .execute().actionGet();
> 
> //index with BulkProcessor  
> void addDocsToBulk(){  
> for(i=0; i\< numDocs; i++)  
> {  
> JSONObject jDoc = getDoc[i];  
> //add the doc to bulk processor
> 
> bulkProcessor.add(Requests.indexRequest(index).type(type).id(jDoc.  
> getString("id")).source(jDoc.toString()));
> 
> //Percolate  
> PercolateResponse response = client.preparePercolate()  
> .setIndices("index")  
> .setDocumentType("type")  
> .setSource(jDoc.toString()).execute().actionGet();  
> //Iterate over the results  
> for(PercolateResponse.Match match : response) {  
> //Handle the result which is the name of  
> //the query in the percolator  
> }
> 
> }

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/285d71ae-40e9-40d7-b7cc-f598bc55263a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/285d71ae-40e9-40d7-b7cc-f598bc55263a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:04am UTC](https://discuss.elastic.co/t/percolation-when-indexing/19612/3 "2017-07-06T01:04:22Z")

</div>


