# Elasticsearch: ('search\_phase\_execution\_exception', 'compile error')

**URL:** <https://discuss.elastic.co/t/elasticsearch-search-phase-execution-exception-compile-error/263146>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [February 3, 2021, 4:09pm UTC](https://discuss.elastic.co/t/elasticsearch-search-phase-execution-exception-compile-error/263146 "2021-02-03T16:09:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikkie](https://avatars.discourse-cdn.com/v4/letter/n/e36b37/32.png) [@Nikkie](https://discuss.elastic.co/u/Nikkie)\
**Post date:** [February 3, 2021, 4:09pm UTC](https://discuss.elastic.co/t/elasticsearch-search-phase-execution-exception-compile-error/263146/1 "2021-02-03T16:09:40Z")

</div>

I am executing script\_query with cosineSimilarity using tensorflow embedding. The embeddings are obtained from tensorflow-hub. model which is loaded using the url:  
"[TensorFlow Hub](https://tfhub.dev/google/universal-sentence-encoder/4)"

I am able to successfully create the index and execute simple search queries. But I get the following error when I try and execute script\_query.  
Query:

```auto
    similar_query = {
        "script_score":{
            "query":{"match_all":{}},
            "script":{
                "source":"cosineSimilarity(params.query_vector, 'vector')+1.0",
                    "params": {
                        "query_vector": query_vector
                    }
            }
        }
    }

```

Error:  
raceback (most recent call last):  
File "similarity\_search.py", line 49, in   
similar\_Utterances(es, query\_string)  
File "similarity\_search.py", line 34, in similar\_Utterances  
response = es.search(index=INDEX\_NAME, body=body)  
File "/home/narora/anaconda3/envs/tf\_env/lib/python3.6/site-packages/elasticsearch/client/utils.py", line 152, in \_wrapped  
return func(\*args, params=params, headers=headers, \*\*kwargs)  
File "/home/narora/anaconda3/envs/tf\_env/lib/python3.6/site-packages/elasticsearch/client/ **init**.py", line 1663, in search  
body=body,  
File "/home/narora/anaconda3/envs/tf\_env/lib/python3.6/site-packages/elasticsearch/transport.py", line 392, in perform\_request  
raise e  
File "/home/narora/anaconda3/envs/tf\_env/lib/python3.6/site-packages/elasticsearch/transport.py", line 365, in perform\_request  
timeout=timeout,  
File "/home/narora/anaconda3/envs/tf\_env/lib/python3.6/site-packages/elasticsearch/connection/http\_urllib3.py", line 269, in perform\_request  
self.\_raise\_error(response.status, raw\_data)  
File "/home/narora/anaconda3/envs/tf\_env/lib/python3.6/site-packages/elasticsearch/connection/base.py", line 316, in \_raise\_error  
status\_code, error\_message, additional\_info  
elasticsearch.exceptions.RequestError: RequestError(400, 'search\_phase\_execution\_exception', 'compile error')

The first time I create the index and execute script query, it works and gives me output but after that simple search queries do work but for script query I get this error.  
I have this code as part of the docker image but the error persists as an independent python script too.  
I have checked the index using localhost:/index\_name and the index structure is accurate.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 3, 2021, 4:10pm UTC](https://discuss.elastic.co/t/elasticsearch-search-phase-execution-exception-compile-error/263146/2 "2021-03-03T16:10:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
