Java api : bulk refresh


(nel.taurisson) #1

Hi,

This is my first post here, so first thanks a lot for the wonderfull
framework.

I'm using java api and I'm wondering if the setRefresh( true ) method
on a BulkRequestBuilder should lead for wainting for all the bulk's
operation to be searchable (as I would expect as this is the behaviour
with an IndexRequestBuilder). In fact, in the following code, it
doesn't, but as I'm very new to es, maybe I'm doing something wrong :

BulkRequestBuilder bulk = this.client.prepareBulk() ;
bulk.setRefresh( true ) ;

bulk.add( this.client.prepareIndex()
.setRefresh( true )
.setIndex( "index1")
.setType( "doc" )
.setId( "1" )
.setSource( "{"name":"toto"}" ) ) ;
bulk.add( this.client.prepareIndex()
.setRefresh( true )
.setIndex( "index1")
.setType( "doc" )
.setId( "2" )
.setSource( "{"name":"titi"}" ) ) ;

BulkResponse response = bulk.execute().actionGet();

GetResponse get = this.client.prepareGet()
.setIndex( "index1" )
.setType( "doc" )
.setId( "1" ).execute().actionGet();

assertTrue( get.exists() ) ; // which fails

Thanks for any help

Nel


(Shay Banon) #2

I fixed a bug that the refresh flag was not being taken into account in master (upcoming 0.15 version). I think you hit it :slight_smile:
On Wednesday, January 26, 2011 at 11:47 AM, nel.taurisson wrote:

Hi,

This is my first post here, so first thanks a lot for the wonderfull
framework.

I'm using java api and I'm wondering if the setRefresh( true ) method
on a BulkRequestBuilder should lead for wainting for all the bulk's
operation to be searchable (as I would expect as this is the behaviour
with an IndexRequestBuilder). In fact, in the following code, it
doesn't, but as I'm very new to es, maybe I'm doing something wrong :

BulkRequestBuilder bulk = this.client.prepareBulk() ;
bulk.setRefresh( true ) ;

bulk.add( this.client.prepareIndex()
.setRefresh( true )
.setIndex( "index1")
.setType( "doc" )
.setId( "1" )
.setSource( "{"name":"toto"}" ) ) ;
bulk.add( this.client.prepareIndex()
.setRefresh( true )
.setIndex( "index1")
.setType( "doc" )
.setId( "2" )
.setSource( "{"name":"titi"}" ) ) ;

BulkResponse response = bulk.execute().actionGet();

GetResponse get = this.client.prepareGet()
.setIndex( "index1" )
.setType( "doc" )
.setId( "1" ).execute().actionGet();

assertTrue( get.exists() ) ; // which fails

Thanks for any help

Nel


(nel.taurisson) #3

great !

2011/1/26 Shay Banon shay.banon@elasticsearch.com:

I fixed a bug that the refresh flag was not being taken into account in
master (upcoming 0.15 version). I think you hit it :slight_smile:

On Wednesday, January 26, 2011 at 11:47 AM, nel.taurisson wrote:

Hi,

This is my first post here, so first thanks a lot for the wonderfull
framework.

I'm using java api and I'm wondering if the setRefresh( true ) method
on a BulkRequestBuilder should lead for wainting for all the bulk's
operation to be searchable (as I would expect as this is the behaviour
with an IndexRequestBuilder). In fact, in the following code, it
doesn't, but as I'm very new to es, maybe I'm doing something wrong :

BulkRequestBuilder bulk = this.client.prepareBulk() ;
bulk.setRefresh( true ) ;

bulk.add( this.client.prepareIndex()
.setRefresh( true )
.setIndex( "index1")
.setType( "doc" )
.setId( "1" )
.setSource( "{"name":"toto"}" ) ) ;
bulk.add( this.client.prepareIndex()
.setRefresh( true )
.setIndex( "index1")
.setType( "doc" )
.setId( "2" )
.setSource( "{"name":"titi"}" ) ) ;

BulkResponse response = bulk.execute().actionGet();

GetResponse get = this.client.prepareGet()
.setIndex( "index1" )
.setType( "doc" )
.setId( "1" ).execute().actionGet();

assertTrue( get.exists() ) ; // which fails

Thanks for any help

Nel


(Rauan Maemirov) #4

Is it fixed in 1.7.1?
With "refresh_interval": "-1", I'm continuously bulking with .refresh(true) on an entire bulk and I'm not seeing up to date counts on my index. After finishing all my bulks I manually send _refresh request and only then I see the valid hits count.


(system) #5