I'd say the problem is in your data and that there are a number of records that have the cityname as an empty value, you should really check your data quality first.
hey warkolm, thanks for the response. well, cityname is just an example, another example would probably be chair, some chair has the arm rest and some don't but there are some chair with very high score. so we want highest score with chair with arm rest sorted to the top.
we thought of a workaround like search on exists field and sort by score or boost negatively on the field that missing so score would be lower.
I haven't tried this but I imagine you could do this with a combination of script sort and field sort. So you would have a script which would return a high number like 10000 if the cityname is present and 0 if not. And then chain that with the field sorts for _score and cityname.
hi colin, thanks for your response. on the code 'YOUR_SCRIPT', could you give some sample? noob here to code script. could you also give url script documentation how to do that?
I'd recommend that you set the language to lucene expressions (see scripting documentation above) to bypass the security concerns around dynamic scripting with groovy (explained at the top of the scripting documentation in the link above). You may also consider storing the script in a file or indexed script.
As I mentioned above, you should set the language for the script to use the lucene expressions language which does not suffer from the same security concerns as the other scripting languages as it is very restrictive in functionality and so works when dynamic scripting is disabled.
You could also save the script as a file (e.g. my_script.groovy) in the $ES_CONF_DIR/scripts folder and then reference the file script in the script sort:
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.