Problem searchingh after update

Hi,

I've just updated to 0.90.10 from 0.90.5, and I'm having some issues with
my unit tests.

Here's the outline of the test

TransportClient c = new TransportClient(settings).addTransportAddress(new
InetSocketTransportAddress("localhost", 9300));
SearchResponse res = c.prepareSearch().setIndices(TEST_INDEX).addFields(
LIST_OF_FIELDS).setQuery(QueryBuilders.matchQuery("id", "<>")).
execute().actionGet();
// do the update
UpdateResponse updateRes = prepareUpdateRequestForDocument(indexName,document
).setScript("<< UPDATE SCRIPT >>").execute().actionGet();

// via REST API, I see the modified document hence the update is applied.
// sleep for a while and repeat search
SearchResponse res = c.prepareSearch().setIndices(TEST_INDEX).addFields(
LIST_OF_FIELDS).setQuery(QueryBuilders.matchQuery("id", "<>")).
execute().actionGet();

SearchHit hit = res.getHits().getAt(0);
// the document returned in the second search is not the updated document.
assert(check document) -> fails

even if I issue

client.admin().indices().prepareRefresh(TEST_INDEX).execute().actionGet();

or

client.admin().indices().prepareFlush(TEST_INDEX).execute().actionGet();

Why am I receiving the non-updated old document from the Java API where I
immediately see the updated document via rest api? What am I missing?

Thanks in advance,
Ukyo

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/71df3e92-cc2d-4b03-acd1-73330e7df914%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hey,

can you check the update response, if it was successful? Usually a refresh
should be sufficient? You are testing the REST API while you are running
this test and the REST works and this test doesnt?

Also can you provide a complete snippet including indexation and all your
calls? The above code doesnt compile and contains many placeholders, so we
cannot a complete picture of what you are doing.. A gist would be great!
Thanks!

--Alex

On Sat, Jan 11, 2014 at 1:07 PM, Ukyo Virgden ukyovirgden@gmail.com wrote:

Hi,

I've just updated to 0.90.10 from 0.90.5, and I'm having some issues with
my unit tests.

Here's the outline of the test

TransportClient c = new TransportClient(settings).addTransportAddress(new
InetSocketTransportAddress("localhost", 9300));
SearchResponse res = c.prepareSearch().setIndices(TEST_INDEX).addFields(
LIST_OF_FIELDS).setQuery(QueryBuilders.matchQuery("id", "<>")).
execute().actionGet();
// do the update
UpdateResponse updateRes = prepareUpdateRequestForDocument(indexName,document
).setScript("<< UPDATE SCRIPT >>").execute().actionGet();

// via REST API, I see the modified document hence the update is applied.
// sleep for a while and repeat search
SearchResponse res = c.prepareSearch().setIndices(TEST_INDEX).addFields(
LIST_OF_FIELDS).setQuery(QueryBuilders.matchQuery("id", "<>")).
execute().actionGet();

SearchHit hit = res.getHits().getAt(0);
// the document returned in the second search is not the updated document.
assert(check document) -> fails

even if I issue

client.admin().indices().prepareRefresh(TEST_INDEX).execute().actionGet();

or

client.admin().indices().prepareFlush(TEST_INDEX).execute().actionGet();

Why am I receiving the non-updated old document from the Java API where I
immediately see the updated document via rest api? What am I missing?

Thanks in advance,
Ukyo

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/71df3e92-cc2d-4b03-acd1-73330e7df914%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGCwEM_0jF9XA0%3DgRs3%2BCaqLKyed%2BBFX0-y_Ysj5Lh5UaQBZ-A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Alex,

It turns out that it was my fault. But this is a tricky one, I'd like to
explain what happened for others to benefit. The issue was that I was not
storing the field that I was updating. Therefore the getValue was returning
empty from the Java API. The reason that I was able to see the updated
document via REST api is that I was seeing the _source field. So I went
back to my mappings, and corrected the store attribute on the field.

Bottom line is _source field already contains the whole document, there's
little point in storing individual fields in Lucene other than highlight
purposes.

Thanks for your answer.

On Tue, Jan 14, 2014 at 1:41 PM, Alexander Reelsen alr@spinscale.de wrote:

Hey,

can you check the update response, if it was successful? Usually a refresh
should be sufficient? You are testing the REST API while you are running
this test and the REST works and this test doesnt?

Also can you provide a complete snippet including indexation and all your
calls? The above code doesnt compile and contains many placeholders, so we
cannot a complete picture of what you are doing.. A gist would be great!
Thanks!

--Alex

On Sat, Jan 11, 2014 at 1:07 PM, Ukyo Virgden ukyovirgden@gmail.comwrote:

Hi,

I've just updated to 0.90.10 from 0.90.5, and I'm having some issues with
my unit tests.

Here's the outline of the test

TransportClient c = new TransportClient(settings).addTransportAddress(new
InetSocketTransportAddress("localhost", 9300));
SearchResponse res = c.prepareSearch().setIndices(TEST_INDEX).addFields(
LIST_OF_FIELDS).setQuery(QueryBuilders.matchQuery("id", "<>")).
execute().actionGet();
// do the update
UpdateResponse updateRes = prepareUpdateRequestForDocument(indexName,document
).setScript("<< UPDATE SCRIPT >>").execute().actionGet();

// via REST API, I see the modified document hence the update is applied.
// sleep for a while and repeat search
SearchResponse res = c.prepareSearch().setIndices(TEST_INDEX).addFields(
LIST_OF_FIELDS).setQuery(QueryBuilders.matchQuery("id", "<>")).
execute().actionGet();

SearchHit hit = res.getHits().getAt(0);
// the document returned in the second search is not the updated document.
assert(check document) -> fails

even if I issue

client.admin().indices().prepareRefresh(TEST_INDEX).execute().actionGet
();

or

client.admin().indices().prepareFlush(TEST_INDEX).execute().actionGet();

Why am I receiving the non-updated old document from the Java API where I
immediately see the updated document via rest api? What am I missing?

Thanks in advance,
Ukyo

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

To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/71df3e92-cc2d-4b03-acd1-73330e7df914%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/TmXih0KvEC0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAGCwEM_0jF9XA0%3DgRs3%2BCaqLKyed%2BBFX0-y_Ysj5Lh5UaQBZ-A%40mail.gmail.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAHZHwzOXLVGQ2_ipduJbjj92MYknwazankhbzqjWacLEH5wjkg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.