This looks funky. I'd remove the word "and" here as it will be a free-text search for the string "and".
Normally the query score and the random score will be multiplied together. To get a pure random score you need to replace the query score with the output of the random score. Do this by adding:
Thank you for "boost_mode" but this is not exact what I need. I more general form requests from my application will contain 2 types of criteria:
Mandatory filter by continent/country
Optional More Like This part, which must be applied if possible (e.g. if additional fields exists)
Results must be sorted in random order if optional part was not applied, but optional part must have more priority over random order while sorting if possible.
It will be simple for me to implement mandatory filter as query_string (which can contain AND and OR - see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html), and I know about weight parameter of score function, but I can't understand how to set 0 weight for mandatory filter, 1 for random sorting and 9 for optional part with More Like This query.
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.