ValueError: Received multiple values for 'size', specify parameters directly instead of using 'body' or 'params'

Viewed 21

My query shows the error ValueError: Received multiple values for 'size', specify parameters directly instead of using 'body' or 'params'

I tried specifying parameters directly however I believe body is needed for this query

helper_token = Tokenizer()
INPUT = input("Enter the Input Query ")
token_vector = helper_token.get_token(INPUT)

query ={
  
   "size":50,
   "_source": "Title", 
   "query":{
      "bool":{
         "must":[
            {
               "knn":{
                  "vectors":{
                     "vector":token_vector,
                     "k":
                  }
               }
            }
         ]
      }
   }
}
es = Elasticsearch(timeout=600,hosts=os.getenv(ENDPOINT))
res = es.search(index='seriousJokers',
                size=30,
                body=query,
                request_timeout=55)

title = [x['_source']  for x in res['hits']['hits']]
title
1 Answers

Remove the size paramter from es.search()

res = es.search(index='seriousJokers',
                body=query,
                request_timeout=55)

Your ES query json has a size field 50, and you are specifying a different value of size 30, while calling the search function.

Hence the error, Received multiple values for size

Related