Mandroid
Mandroid

Reputation: 7468

Elasticsearch query returning far less number of records

I am running following elasticsearch query from groovy script. There are thousands of records which meet this criteria, but I get only 10 records in return.

{ 
"query":{ 
  "bool":{ 
     "must":[ 
        { 
           "match_all":{ 

           }
        },
        { 
           "range":{ 
              "@Timestamp":{ 
                 "gte":1417511269270,
                 "lte":1575277669270,
                 "format":"epoch_millis"
              }
           }
        },
        { 
           "match_phrase":{ 
              "field1.keyword":{ 
                 "query":"value1"
              }
           }
        },
        { 
           "match_phrase":{ 
              "field2.keyword":{ 
                 "query":"value2"
              }
           }
        },
        { 
           "range":{ 
              "@Timestamp":{ 
                 "gte":"2001-03-01",
                 "lt":"2019-10-30"
              }
           }
        }
     ],
     "filter":[ 

     ],
     "should":[ 

     ],
     "must_not":[ 

     ]
  }
 }
}

What am I missing in my query?

Upvotes: 0

Views: 166

Answers (1)

Adam T
Adam T

Reputation: 1691

You are missing a size parameter, which means it defaults to 10 results.

e.g. add this to your query object:

"size": 100

Upvotes: 3

Related Questions