I am extremely new to elasticsearch so be gentle, please.
I would like to get some advice on a mapping problem I am facing. I know that a type, once set, cannot be changed so if it is a string has to be a string throughout the same index.
Let's say I have got recipes to store in ES. Recipes have ingredients and each ingredient has a name and a quantity
The problem I have got is that quantity can be expressed numerically or as a string (e.g. 'a tablespoon')
So the question is shall I treat everything as a string or are there some clever solutions to this very kind of mapping problem? And If I treat everything as a string, would I loose the possibility to query something like "give me recipes where eggs > 3"?
if now I query for recipes with any ingredient which has a quantity more than 5 I get the second one has expected, but unfortunately the quantity.numeric field even if it is an integer it is still sorted lexicographically, in fact if I put a recipes with 20 eggs and query again for something with quantity greater than 5 I still get one recipe back. Only If I query for gte 2 I also get the 20 eggs recipe.
So, although it was promising, the trick is useless due to how the 'integer' is still treated as a 'string'.
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.