Indexing stops after 1000 records

I'm trying to reindex using logstash. I have total 25000 recodrs that are to be indexed. Whenever I run the following logstash file, it stops at 1000 records. Is there anything that I have to change in the following logstash file???

input
{
elasticsearch
{
host => [ "localhost" ]
index => "sample"
#size => 100
}
}

filter
{
mutate
{
gsub => ["Summary","Mr.(\w)\w* (\w)\w*","***"]
}
}

output
{
elasticsearch_http
{
host => "localhost"
index => "sample"
index_type => "sample"
}
stdout
{
codec => "json"
}
}

Have tried giving size. If I use size, it stops at 5000 records. If increase the size further, the following error is coming up

Plugin: <LogStash::Inputs::Elasticsearch host=>"localhost", index=>"sample", query=>"*", scroll=>"1m">
Error: Java heap space {:level=>:error}←[0m

Don't know what to do. Because of this, I am not able to move further.