Different response for same query


(barnash) #1

Hi,

We are running a query using the elastic search head application and
it seems like we are getting the same results but in different order.
The strangest thing is that every second time we run the query, we get
the same result.
So for example this is the query we run:

{
"query": {
"wildcard": {
"foo": "bar*"
}
}
}

And here are the two results we are getting:
Response A:
Total: 3045177
hits: a, b, c ,d, e...

Response B:
Total: 3045177
hits: f, g, h, i, j...

If we run the query again and again, we consistently get these
results:
A, B, A, B, A, B, A, B, ...

We don't understand why this is happening and how can we fix it.
Can someone please advise?

Thanks,
Iftach


(Klerisson) #2

I got the same once, but the problem was related to the CouchDB
documents' revision.

Somehow the updated docs were not getting indexed by ES (river), and
even more, I submitted the same query twice and got docs from the n-
revision first and (n+1)-revision after.

Regards,

On Apr 29, 12:48 pm, barnash iftach...@gmail.com wrote:

Hi,

We are running a query using the elastic search head application and
it seems like we are getting the same results but in different order.
The strangest thing is that every second time we run the query, we get
the same result.
So for example this is the query we run:

{
"query": {
"wildcard": {
"foo": "bar*"
}
}

}

And here are the two results we are getting:
Response A:
Total: 3045177
hits: a, b, c ,d, e...

Response B:
Total: 3045177
hits: f, g, h, i, j...

If we run the query again and again, we consistently get these
results:
A, B, A, B, A, B, A, B, ...

We don't understand why this is happening and how can we fix it.
Can someone please advise?

Thanks,
Iftach


(Shay Banon) #3

Order between same score documents is not guaranteed, especially when a
search will hit different copies of a shard. Wildcard queries usually end
up being a constant score query (and are expensive to execute, don't use
them, use ngram based indexing instead).

You can provide a preference flag to the search request, for example, a
session id or something similar, so a "user" will always hit the same shard
and get a bit more consistent results. See more here:
http://www.elasticsearch.org/guide/reference/api/search/preference.html.

On Sun, Apr 29, 2012 at 6:48 PM, barnash iftachbar@gmail.com wrote:

Hi,

We are running a query using the elastic search head application and
it seems like we are getting the same results but in different order.
The strangest thing is that every second time we run the query, we get
the same result.
So for example this is the query we run:

{
"query": {
"wildcard": {
"foo": "bar*"
}
}
}

And here are the two results we are getting:
Response A:
Total: 3045177
hits: a, b, c ,d, e...

Response B:
Total: 3045177
hits: f, g, h, i, j...

If we run the query again and again, we consistently get these
results:
A, B, A, B, A, B, A, B, ...

We don't understand why this is happening and how can we fix it.
Can someone please advise?

Thanks,
Iftach


(system) #4