1

I am trying to do a binary search on a huge array (sorted_keys) sorted_keys.length = 250,000

my_script = f"""
         if (Arrays.binarySearch({sorted_keys}, doc['_meta.key'].value) > 0)) return 0; 
         return 1;
        """
        script = {"script": {"lang": "painless", "source": my_script }}

However this script gives me a compiling error, elasticsearch7.exceptions.RequestError: RequestError(400, 'search_phase_execution_exception', 'compile error')

According to the docs it should be available https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-api-reference-shared.html#_java_util

How can I use Arrays.binarySearch in painless?

1 Answer 1

2

binarySearch is available under Collections in painless unlike Java

so changing Arrays to Collections solved my problem

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.