Search code examples
pythonelasticsearchamazon-opensearch

Elasticsearch 6.2.0 does not honour size parameter - always returns 10 docs


I'm using the Elasticsearch 6.2.0 Python client and querying an Amazon Opensearch 1.1 index. No matter what value I set the "size" parameter to in Python for a particular search term that I know has over 1000 matches, exactly 10 matching documents are returned. However, when I query the index using curl, if I specify a size of 30, I (correctly) get 30 matching documents.

This is my query:

query_term = "diabetes"

body = {
    'from' : 0, 'size' : 30,
    'query': {
        'bool': {
            'must': {
                'match': { 'term': query_term }
            },
            'filter': {
                'term': { 'type': "concept" }
            }
        }
    },
}

response = self.es.search(body=body)

Any idea what I'm doing wrong?


Solution

  • most likely, the size you provided in the json body was overwritten by the default size value (10) set by the search api: https://elasticsearch-py.readthedocs.io/en/v8.6.2/api.html#elasticsearch.client.EqlClient.search

    try with

    response = self.es.search(body=body, size=30)