I know this is an edge case, but...
I have a search with a field sort (using Java API) that throws an exception
if the index is empty.
I believe this is because my empty index has no mappings defined, and the
sort cannot figure out the data type of the field in question (even though
there are no results to sort). What is the best way to deal with this case?
I can think of a couple of ways:
- Insert a dummy record so ES can determine the mappings (kind of hacky)
- Define explicit mappings when I create the index (a little annoying,
since I find the default mappings useful and would prefer to use them)
- Do an additional index status request first to see if the document count
is zero (has to be done on every request)
- Catch the exception (seems dangerous because I don't think I get the
real cause (missing mapping) except as part of the message text)
- other ideas?