Faceting search error

I am getting a weird exception[0] when doing a faceted search on an index
alias. I couldn't come up with a script that reproduces this behaviour.
This should be a cache invalidation issue because clearing the cache
fixes the problem and everything works as expected, perhaps inserting a
document on an aliased index (with a routing value) doesn't correctly
expire caches.

The flow is something like this:

  • do the query with zero matching docs
  • add a doc
  • redoing the query fails with the specified error
  • empty caches
  • query works

gist: https://gist.github.com/d2a223467c9e266b0ce0

[0] ClassCastException
[org.elasticsearch.index.field.data.strings.SingleValueStringFieldData
cannot be cast to
org.elasticsearch.index.field.data.longs.LongFieldData]

Is there a chance that you did the query against an index that has no document with the mentioned field (thus no mapping)? In this case, the type of the field will be guessed to be "string" (we need to do that before we execute the query), and then, when you index a document with a numeric type, you will get this failure (and clear cache will fix it).

On Tuesday, March 13, 2012 at 3:46 PM, Christos Trochalakis wrote:

I am getting a weird exception[0] when doing a faceted search on an index
alias. I couldn't come up with a script that reproduces this behaviour.
This should be a cache invalidation issue because clearing the cache
fixes the problem and everything works as expected, perhaps inserting a
document on an aliased index (with a routing value) doesn't correctly
expire caches.

The flow is something like this:

  • do the query with zero matching docs
  • add a doc
  • redoing the query fails with the specified error
  • empty caches
  • query works

gist: elastic faceting issue · GitHub

[0] ClassCastException
[org.elasticsearch.index.field.data.strings.SingleValueStringFieldData
cannot be cast to
org.elasticsearch.index.field.data.longs.LongFieldData]

On Wed, Mar 14, 2012 at 02:09:15PM +0200, Shay Banon wrote:

On Tuesday, March 13, 2012 at 3:46 PM, Christos Trochalakis wrote:

I am getting a weird exception[0] when doing a faceted search on an index
alias. I couldn't come up with a script that reproduces this behaviour.
This should be a cache invalidation issue because clearing the cache
fixes the problem and everything works as expected, perhaps inserting a
document on an aliased index (with a routing value) doesn't correctly
expire caches.

The flow is something like this:

  • do the query with zero matching docs
  • add a doc
  • redoing the query fails with the specified error
  • empty caches
  • query works

gist: elastic faceting issue · GitHub

[0] ClassCastException
[org.elasticsearch.index.field.data.strings.SingleValueStringFieldData
cannot be cast to
org.elasticsearch.index.field.data.longs.LongFieldData]

Is there a chance that you did the query against an index that has no document with the mentioned field (thus no mapping)? In this case, the type of the field will be guessed to be "string" (we need to do that before we execute the query), and then, when you index a document with a numeric type, you will get this failure (and clear cache will fix it).

Yes, this is exactly the case. I just created a bug report