(no subject)


(Abhishek Jajoria) #1

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


(David Pilato) #2

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

See http://www.elasticsearch.org/guide/reference/api/percolate.html

HTH
David :wink:
@dadoonet

Le 28 févr. 2012 à 08:01, jajoria abhishek 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


(Shay Banon) #3

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


(Abhishek Jajoria) #4

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 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


(Shay Banon) #5

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.

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)> 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


(system) #6