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
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!
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
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!
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
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.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.