title: Get RequestError(400, 'search_phase_execution_exception', 'runtime error') for cossimilarity
body: <p>I am trying to do semantic search with Elasticsearch using tensorflow_hub, but I get <code>RequestError: RequestError(400, 'search_phase_execution_exception', 'runtime error') </code>. From search_phase_execution_exception I suppose that with corrupted data(<a href="https://stackoverflow.com/questions/30073759/searchphaseexecutionexceptionfailed-to-execute-phase-query-all-shards-failed">from this stack question</a>) My document structure looks like this</p>
  <pre><code>{
  &quot;settings&quot;: {
    &quot;number_of_shards&quot;: 2,
    &quot;number_of_replicas&quot;: 1
  },
   &quot;mappings&quot;: {
    &quot;dynamic&quot;: &quot;true&quot;,
    &quot;_source&quot;: {
      &quot;enabled&quot;: &quot;true&quot;
    },
    &quot;properties&quot;: {
          &quot;id&quot;: {
              &quot;type&quot;:&quot;keyword&quot;
          },
          &quot;title&quot;: {
              &quot;type&quot;: &quot;text&quot;
          },
          &quot;abstract&quot;: {
              &quot;type&quot;: &quot;text&quot;
          },
          &quot;abs_emb&quot;: {
              &quot;type&quot;:&quot;dense_vector&quot;,
              &quot;dims&quot;:512
          },
          &quot;timestamp&quot;: {
              &quot;type&quot;:&quot;date&quot;
          }
      }
  }
  }
  </code></pre>
  <p>And I create a document using <code>elasticsearch.indices.create</code>.</p>
  <pre><code>es.indices.create(index=index, body='my_document_structure')
  res = es.indices.delete(index=index, ignore=[404])
  for i in range(100):
    doc = {
      'timestamp': datetime.datetime.utcnow(),
      'id':id[i],
      'title':title[0][i],
      'abstract':abstract[0][i],
      'abs_emb':tf_hub_KerasLayer([abstract[0][i]])[0]
    }
    res = es.index(index=index, body=doc)
  </code></pre>
  <p>for my semantic search I use this code</p>
  <p>query = &quot;graphene&quot;
  query_vector = list(embed([query])[0])</p>
  <pre><code>script_query = {
      &quot;script_score&quot;: {
          &quot;query&quot;: {&quot;match_all&quot;: {}},
          &quot;script&quot;: {
              &quot;source&quot;: &quot;cosineSimilarity(params.query_vector, doc['abs_emb']) + 1.0&quot;,
              &quot;params&quot;: {&quot;query_vector&quot;: query_vector}
          }
      }
  }
  
  response = es.search(
      index=index,
      body={
          &quot;size&quot;: 5,
          &quot;query&quot;: script_query,
          &quot;_source&quot;: {&quot;includes&quot;: [&quot;title&quot;, &quot;abstract&quot;]}
      }
  )
  </code></pre>
  <p>I know there are some similar questions in stackoverflow and elsasticsearch, but I couldn't find solution for me. My guess is that the document structure is wrong but I can't figure out what exactly. I used search query code from <a href="https://github.com/jtibshirani/text-embeddings/blob/blog/src/main.py" rel="nofollow noreferrer">this</a> repo. The full error message is too long and doesn't seem to contain much information, so I share only last part of it.</p>
  <pre><code>~/untitled/elastic/venv/lib/python3.9/site-packages/elasticsearch/connection/base.py in 
  _raise_error(self, status_code, raw_data)
  320             logger.warning(&quot;Undecodable raw error response from server: %s&quot;, err)
  321 
  --&gt; 322         raise HTTP_EXCEPTIONS.get(status_code, TransportError)(
  323             status_code, error_message, additional_info
  324         )
  
  RequestError: RequestError(400, 'search_phase_execution_exception', 'runtime error')
  </code></pre>
  <p>An here is the Error from Elasticsearch server.</p>
  <pre><code>[2021-04-29T12:43:07,797][WARN ][o.e.c.r.a.DiskThresholdMonitor] 
  [asmac.local] high disk watermark [90%] exceeded on 
  [w7lUacguTZWH9xc_lyd0kg][asmac.local][/Users/username/elasticsearch- 
  7.12.0/data/nodes/0] free: 17.2gb[7.4%], shards will be relocated 
  away from this node; currently relocating away shards totalling [0] 
  bytes; the node is expected to continue to exceed the high disk 
  watermark when these relocations are complete
  </code></pre>