# (no subject)

**URL:** <https://discuss.elastic.co/t/no-subject/6824>\
**Category:** Elasticsearch\
**Created:** [February 28, 2012, 7:01am UTC](https://discuss.elastic.co/t/no-subject/6824 "2012-02-28T07:01:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_Jajoria](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@Abhishek\_Jajoria](https://discuss.elastic.co/u/Abhishek_Jajoria)\
**Post date:** [February 28, 2012, 7:01am UTC](https://discuss.elastic.co/t/no-subject/6824/1 "2012-02-28T07:01:56Z")

</div>

I am working with percolate . Here is what I am doing

QueryBuilder qb = termQuery("content", "amazing");

client.prepareIndex("percator", "myType", "kuku")  
.setSource(qb.toString())  
.setRefresh(true)  
.execute().actionGet();

With above code it creates an index name percator  
Now I want to send document so that it matches the query

XContentBuilder docBuilder = XContentFactory.jsonBuilder().startObject();

```
docBuilder.field("doc").startObject();
docBuilder.field("content","amazing");
docBuilder.endObject();
docBuilder.endObject();

```

PercolateResponse response =client.preparePercolate("percator",  
"myType").setSource(docBuilder).execute().actionGet();  
but the response get the 0 results what I am doing wrong

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 28, 2012, 7:18am UTC](https://discuss.elastic.co/t/no-subject/6824/2 "2012-02-28T07:18:03Z")

</div>

You just defined a percolator.  
You must put then documents in your index.

See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/percolate.html)

HTH  
David 😉  
@dadoonet

Le 28 févr. 2012 à 08:01, jajoria abhishek [jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) a écrit :

> I am working with percolate . Here is what I am doing
> 
> QueryBuilder qb = termQuery("content", "amazing");
> 
> client.prepareIndex("percator", "myType", "kuku")  
> .setSource(qb.toString())  
> .setRefresh(true)  
> .execute().actionGet();
> 
> With above code it creates an index name percator  
> Now I want to send document so that it matches the query
> 
> XContentBuilder docBuilder = XContentFactory.jsonBuilder().startObject();
> 
> ```
> docBuilder.field("doc").startObject();
> docBuilder.field("content","amazing");
> docBuilder.endObject();
> docBuilder.endObject();
> 
> ```
> 
> PercolateResponse response =client.preparePercolate("percator", "myType").setSource(docBuilder).execute().actionGet();  
> but the response get the 0 results what I am doing wrong

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 29, 2012, 1:49pm UTC](https://discuss.elastic.co/t/no-subject/6824/3 "2012-02-29T13:49:27Z")

</div>

Why do you call toString on the query builder?

On Tuesday, February 28, 2012 at 9:01 AM, jajoria abhishek wrote:

> I am working with percolate . Here is what I am doing
> 
> QueryBuilder qb = termQuery("content", "amazing");
> 
> client.prepareIndex("percator", "myType", "kuku")  
> .setSource(qb.toString())  
> .setRefresh(true)  
> .execute().actionGet();
> 
> With above code it creates an index name percator  
> Now I want to send document so that it matches the query
> 
> XContentBuilder docBuilder = XContentFactory.jsonBuilder().startObject();
> 
> ```
> docBuilder.field("doc").startObject();
> docBuilder.field("content","amazing");
> docBuilder.endObject();
> docBuilder.endObject();
> 
> ```
> 
> PercolateResponse response =client.preparePercolate("percator", "myType").setSource(docBuilder).execute().actionGet();  
> but the response get the 0 results what I am doing wrong

---

<div class="post-metadata">

**Author:** ![Abhishek\_Jajoria](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@Abhishek\_Jajoria](https://discuss.elastic.co/u/Abhishek_Jajoria)\
**Post date:** [March 1, 2012, 12:02pm UTC](https://discuss.elastic.co/t/no-subject/6824/4 "2012-03-01T12:02:52Z")

</div>

Sir with this method

client.prepareIndex("\_percolator", "myIndexName", "myDesignatedQueryName")  
.setSource(qb)  
.setRefresh(true) //Needed when the query shall be available immediately  
.execute().actionGet();

IT shows error in setSource() as no suitable method found for  
setSource(org.elasticsearch.index.query.QueryBuilder)

On Wed, Feb 29, 2012 at 7:19 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> Why do you call toString on the query builder?
> 
> On Tuesday, February 28, 2012 at 9:01 AM, jajoria abhishek wrote:
> 
> I am working with percolate . Here is what I am doing
> 
> QueryBuilder qb = termQuery("content", "amazing");
> 
> client.prepareIndex("percator", "myType", "kuku")  
> .setSource(qb.toString())  
> .setRefresh(true)  
> .execute().actionGet();
> 
> With above code it creates an index name percator  
> Now I want to send document so that it matches the query
> 
> XContentBuilder docBuilder = XContentFactory.jsonBuilder().startObject();
> 
> ```
> docBuilder.field("doc").startObject();
> docBuilder.field("content","amazing");
> docBuilder.endObject();
> docBuilder.endObject();
> 
> ```
> 
> PercolateResponse response =client.preparePercolate("percator",  
> "myType").setSource(docBuilder).execute().actionGet();  
> but the response get the 0 results what I am doing wrong

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 1, 2012, 12:46pm UTC](https://discuss.elastic.co/t/no-subject/6824/5 "2012-03-01T12:46:39Z")

</div>

Here is a sample of how you can use the Java API to do percolation: [https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/test/integration/percolator/SimplePercolatorTests.java#L81](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/test/integration/percolator/SimplePercolatorTests.java#L81).

On Thursday, March 1, 2012 at 2:02 PM, jajoria abhishek wrote:

> Sir with this method  
> client.prepareIndex("\_percolator", "myIndexName", "myDesignatedQueryName")  
> .setSource(qb)  
> .setRefresh(true) //Needed when the query shall be available immediately  
> .execute().actionGet(); IT shows error in setSource() as no suitable method found for setSource(org.elasticsearch.index.query.QueryBuilder)
> 
> On Wed, Feb 29, 2012 at 7:19 PM, Shay Banon \<[kimchy@gmail.com](mailto:kimchy@gmail.com) ([mailto:kimchy@gmail.com](mailto:kimchy@gmail.com))\> wrote:
> 
> > Why do you call toString on the query builder?
> > 
> > On Tuesday, February 28, 2012 at 9:01 AM, jajoria abhishek wrote:
> > 
> > > I am working with percolate . Here is what I am doing
> > > 
> > > QueryBuilder qb = termQuery("content", "amazing");
> > > 
> > > client.prepareIndex("percator", "myType", "kuku")  
> > > .setSource(qb.toString())  
> > > .setRefresh(true)  
> > > .execute().actionGet();
> > > 
> > > With above code it creates an index name percator  
> > > Now I want to send document so that it matches the query
> > > 
> > > XContentBuilder docBuilder = XContentFactory.jsonBuilder().startObject();
> > > 
> > > ```
> > > docBuilder.field("doc").startObject();
> > > docBuilder.field("content","amazing");
> > > docBuilder.endObject();
> > > docBuilder.endObject();
> > > 
> > > ```
> > > 
> > > PercolateResponse response =client.preparePercolate("percator", "myType").setSource(docBuilder).execute().actionGet();  
> > > but the response get the 0 results what I am doing wrong

---

<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, 3:37am UTC](https://discuss.elastic.co/t/no-subject/6824/6 "2017-07-06T03:37:41Z")

</div>


