Inexplicable wrong results in automated tests


(John D. Ament) #1

Hi

So after running a few rounds of local automated tests, I've noticed that
sometimes I get the wrong results in my index. This seems to only be an
issue with my automated tests and not when running the application manually
(at least I haven't seen the wrong results after several executions).

My search looks like this:

SearchResponse searchResponse =
esClient.client().prepareSearch(indexName).setTypes(RECORD_TYPE)
.setFetchSource(true)
.setPostFilter(FilterBuilders.andFilter(
FilterBuilders.inFilter("typeId",types.toArray(new
Integer[]{})).cache(false),

FilterBuilders.inFilter("stateId",states.toArray(new
Integer[]{})).cache(false)
).cache(false))
.addSort("dateCreated.value", SortOrder.DESC)
.addSort("recordId",SortOrder.DESC)
.execute().actionGet();

The issue appears both with and without the cache flag passed in.

The way my tests work is that I execute a bunch of seeds, then run queries
against the seeds to verify I get the right results. I'll create 5 records
in my test, where the typeId's are always 1,2,3,4 and the stateIds are
anything between 1 and 14, except for 6.

5 is a special state in my case. I only want to include that state
sometimes. So I'll run one query with all the states except 5 and 6. I
expect that this will give me 4 records back (the 5th record is in state
5). Instead I'm getting back 5 results, as if ES is also including state 5
in the list even though I didn't want it.

In my test I run this query twice. The test fails sometimes on the first
execution, never on the second execution (I have an arquillian deployment,
and start up the app once, then seed data, run the first query in one test
method, run the second query in a second test method). I'm assuming that
these filters are acting like a pure AND - the record must match both
fields to be returned. So, any idea why I might be getting the wrong
results?

John

--
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/c65c050a-2898-4065-b3a5-c8ad0cda0ed1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Ivan Brusic) #2

Are you refreshing the index after inserting the test documents? I could be
simply a matter of timing.

--
Ivan

On Sun, Aug 3, 2014 at 8:22 AM, John D. Ament john.d.ament@gmail.com
wrote:

Hi

So after running a few rounds of local automated tests, I've noticed that
sometimes I get the wrong results in my index. This seems to only be an
issue with my automated tests and not when running the application manually
(at least I haven't seen the wrong results after several executions).

My search looks like this:

SearchResponse searchResponse =
esClient.client().prepareSearch(indexName).setTypes(RECORD_TYPE)
.setFetchSource(true)
.setPostFilter(FilterBuilders.andFilter(
FilterBuilders.inFilter("typeId",types.toArray(new
Integer[]{})).cache(false),

FilterBuilders.inFilter("stateId",states.toArray(new
Integer[]{})).cache(false)
).cache(false))
.addSort("dateCreated.value", SortOrder.DESC)
.addSort("recordId",SortOrder.DESC)
.execute().actionGet();

The issue appears both with and without the cache flag passed in.

The way my tests work is that I execute a bunch of seeds, then run queries
against the seeds to verify I get the right results. I'll create 5 records
in my test, where the typeId's are always 1,2,3,4 and the stateIds are
anything between 1 and 14, except for 6.

5 is a special state in my case. I only want to include that state
sometimes. So I'll run one query with all the states except 5 and 6. I
expect that this will give me 4 records back (the 5th record is in state
5). Instead I'm getting back 5 results, as if ES is also including state 5
in the list even though I didn't want it.

In my test I run this query twice. The test fails sometimes on the first
execution, never on the second execution (I have an arquillian deployment,
and start up the app once, then seed data, run the first query in one test
method, run the second query in a second test method). I'm assuming that
these filters are acting like a pure AND - the record must match both
fields to be returned. So, any idea why I might be getting the wrong
results?

John

--
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/c65c050a-2898-4065-b3a5-c8ad0cda0ed1%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/c65c050a-2898-4065-b3a5-c8ad0cda0ed1%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/CALY%3DcQAGYAseFmXpbQ%2BOGV_toCmjrGGT7A3LqFmLwhsLi6Oxkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(John D. Ament) #3

I would think timing as an issue if I got a shorter list of results. I'm
getting too many results in this case.

On Monday, August 4, 2014 12:03:35 PM UTC-4, Ivan Brusic wrote:

Are you refreshing the index after inserting the test documents? I could
be simply a matter of timing.

--
Ivan

On Sun, Aug 3, 2014 at 8:22 AM, John D. Ament <john.d...@gmail.com
<javascript:>> wrote:

Hi

So after running a few rounds of local automated tests, I've noticed that
sometimes I get the wrong results in my index. This seems to only be an
issue with my automated tests and not when running the application manually
(at least I haven't seen the wrong results after several executions).

My search looks like this:

SearchResponse searchResponse =
esClient.client().prepareSearch(indexName).setTypes(RECORD_TYPE)
.setFetchSource(true)
.setPostFilter(FilterBuilders.andFilter(

FilterBuilders.inFilter("typeId",types.toArray(new
Integer[]{})).cache(false),

FilterBuilders.inFilter("stateId",states.toArray(new
Integer[]{})).cache(false)
).cache(false))
.addSort("dateCreated.value", SortOrder.DESC)
.addSort("recordId",SortOrder.DESC)
.execute().actionGet();

The issue appears both with and without the cache flag passed in.

The way my tests work is that I execute a bunch of seeds, then run
queries against the seeds to verify I get the right results. I'll create 5
records in my test, where the typeId's are always 1,2,3,4 and the stateIds
are anything between 1 and 14, except for 6.

5 is a special state in my case. I only want to include that state
sometimes. So I'll run one query with all the states except 5 and 6. I
expect that this will give me 4 records back (the 5th record is in state
5). Instead I'm getting back 5 results, as if ES is also including state 5
in the list even though I didn't want it.

In my test I run this query twice. The test fails sometimes on the first
execution, never on the second execution (I have an arquillian deployment,
and start up the app once, then seed data, run the first query in one test
method, run the second query in a second test method). I'm assuming that
these filters are acting like a pure AND - the record must match both
fields to be returned. So, any idea why I might be getting the wrong
results?

John

--
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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/c65c050a-2898-4065-b3a5-c8ad0cda0ed1%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/c65c050a-2898-4065-b3a5-c8ad0cda0ed1%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/8930edda-a02d-4765-890e-8f89f47a5451%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Jörg Prante) #4

Is it possible to provide a minimal test case with docs to reproduce this?

Jörg

On Mon, Aug 4, 2014 at 8:05 PM, John D. Ament john.d.ament@gmail.com
wrote:

I would think timing as an issue if I got a shorter list of results. I'm
getting too many results in this case.

On Monday, August 4, 2014 12:03:35 PM UTC-4, Ivan Brusic wrote:

Are you refreshing the index after inserting the test documents? I could
be simply a matter of timing.

--
Ivan

On Sun, Aug 3, 2014 at 8:22 AM, John D. Ament john.d...@gmail.com
wrote:

Hi

So after running a few rounds of local automated tests, I've noticed
that sometimes I get the wrong results in my index. This seems to only be
an issue with my automated tests and not when running the application
manually (at least I haven't seen the wrong results after several
executions).

My search looks like this:

SearchResponse searchResponse = esClient.client().
prepareSearch(indexName).setTypes(RECORD_TYPE)
.setFetchSource(true)
.setPostFilter(FilterBuilders.andFilter(
FilterBuilders.inFilter("typeId",types.toArray(new
Integer[]{})).cache(false),
FilterBuilders.inFilter("stateId",states.toArray(new
Integer[]{})).cache(false)
).cache(false))
.addSort("dateCreated.value", SortOrder.DESC)
.addSort("recordId",SortOrder.DESC)
.execute().actionGet();

The issue appears both with and without the cache flag passed in.

The way my tests work is that I execute a bunch of seeds, then run
queries against the seeds to verify I get the right results. I'll create 5
records in my test, where the typeId's are always 1,2,3,4 and the stateIds
are anything between 1 and 14, except for 6.

5 is a special state in my case. I only want to include that state
sometimes. So I'll run one query with all the states except 5 and 6. I
expect that this will give me 4 records back (the 5th record is in state
5). Instead I'm getting back 5 results, as if ES is also including state 5
in the list even though I didn't want it.

In my test I run this query twice. The test fails sometimes on the
first execution, never on the second execution (I have an arquillian
deployment, and start up the app once, then seed data, run the first query
in one test method, run the second query in a second test method). I'm
assuming that these filters are acting like a pure AND - the record must
match both fields to be returned. So, any idea why I might be getting the
wrong results?

John

--
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 elasticsearc...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/
msgid/elasticsearch/c65c050a-2898-4065-b3a5-c8ad0cda0ed1%
40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/c65c050a-2898-4065-b3a5-c8ad0cda0ed1%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/8930edda-a02d-4765-890e-8f89f47a5451%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/8930edda-a02d-4765-890e-8f89f47a5451%40googlegroups.com?utm_medium=email&utm_source=footer
.

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

--
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/CAKdsXoEQQq4iUgwxcp__yaQ%2B9cbqbfxD%3DzAvmxy5%2BguYK9%3DrNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(Tihomir Lichev) #5

I also had timing problems in my automated tests, the solution was to
invoke index refresh and wait for it, then execute any search requests.
This way you can make sure that all test data is ready for searching.

03 август 2014, неделя, 18:22:50 UTC+3, John D. Ament написа:

Hi

So after running a few rounds of local automated tests, I've noticed that
sometimes I get the wrong results in my index. This seems to only be an
issue with my automated tests and not when running the application manually
(at least I haven't seen the wrong results after several executions).

My search looks like this:

SearchResponse searchResponse =
esClient.client().prepareSearch(indexName).setTypes(RECORD_TYPE)
.setFetchSource(true)
.setPostFilter(FilterBuilders.andFilter(
FilterBuilders.inFilter("typeId",types.toArray(new
Integer[]{})).cache(false),

FilterBuilders.inFilter("stateId",states.toArray(new
Integer[]{})).cache(false)
).cache(false))
.addSort("dateCreated.value", SortOrder.DESC)
.addSort("recordId",SortOrder.DESC)
.execute().actionGet();

The issue appears both with and without the cache flag passed in.

The way my tests work is that I execute a bunch of seeds, then run queries
against the seeds to verify I get the right results. I'll create 5 records
in my test, where the typeId's are always 1,2,3,4 and the stateIds are
anything between 1 and 14, except for 6.

5 is a special state in my case. I only want to include that state
sometimes. So I'll run one query with all the states except 5 and 6. I
expect that this will give me 4 records back (the 5th record is in state
5). Instead I'm getting back 5 results, as if ES is also including state 5
in the list even though I didn't want it.

In my test I run this query twice. The test fails sometimes on the first
execution, never on the second execution (I have an arquillian deployment,
and start up the app once, then seed data, run the first query in one test
method, run the second query in a second test method). I'm assuming that
these filters are acting like a pure AND - the record must match both
fields to be returned. So, any idea why I might be getting the wrong
results?

John

--
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/16211527-5442-4e0e-ae64-62a0f30253d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(John D. Ament) #6

Hmm. So how do I invoke a reindex via the java API?

On Tue, Aug 5, 2014 at 3:40 AM, Tihomir Lichev shoteff@gmail.com wrote:

I also had timing problems in my automated tests, the solution was to
invoke index refresh and wait for it, then execute any search requests.
This way you can make sure that all test data is ready for searching.

03 август 2014, неделя, 18:22:50 UTC+3, John D. Ament написа:

Hi

So after running a few rounds of local automated tests, I've noticed that
sometimes I get the wrong results in my index. This seems to only be an
issue with my automated tests and not when running the application manually
(at least I haven't seen the wrong results after several executions).

My search looks like this:

SearchResponse searchResponse = esClient.client().
prepareSearch(indexName).setTypes(RECORD_TYPE)
.setFetchSource(true)
.setPostFilter(FilterBuilders.andFilter(
FilterBuilders.inFilter("typeId",types.toArray(new
Integer[]{})).cache(false),
FilterBuilders.inFilter("stateId",states.toArray(new
Integer[]{})).cache(false)
).cache(false))
.addSort("dateCreated.value", SortOrder.DESC)
.addSort("recordId",SortOrder.DESC)
.execute().actionGet();

The issue appears both with and without the cache flag passed in.

The way my tests work is that I execute a bunch of seeds, then run
queries against the seeds to verify I get the right results. I'll create 5
records in my test, where the typeId's are always 1,2,3,4 and the stateIds
are anything between 1 and 14, except for 6.

5 is a special state in my case. I only want to include that state
sometimes. So I'll run one query with all the states except 5 and 6. I
expect that this will give me 4 records back (the 5th record is in state
5). Instead I'm getting back 5 results, as if ES is also including state 5
in the list even though I didn't want it.

In my test I run this query twice. The test fails sometimes on the first
execution, never on the second execution (I have an arquillian deployment,
and start up the app once, then seed data, run the first query in one test
method, run the second query in a second test method). I'm assuming that
these filters are acting like a pure AND - the record must match both
fields to be returned. So, any idea why I might be getting the wrong
results?

John

--
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/uy0YrsXXw44/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/16211527-5442-4e0e-ae64-62a0f30253d0%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/16211527-5442-4e0e-ae64-62a0f30253d0%40googlegroups.com?utm_medium=email&utm_source=footer
.

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

--
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/CAOqetn8Yg3--qYSCvy60B_iqro7abU_cAEG%2BC7-HuzmDpogOfQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(Tihomir Lichev) #7

Sort of:

TransportClient transportClient = new TransportClient(settings); // just
an example of transport client instantiation, you can use your own

transportClient.getClient().admin().indices().refresh(Requests
.refreshRequest(indexName)).actionGet(); // actionGet() as you may know it
to make the call synchronous and wait for it until done (otherwise it is
async)

--
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/348578e9-4fd1-4209-8995-1637c963fe70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #8