hitsPerPage

scope settings search
type integer
default 20
description

Set the number of hits per page.

This can be set at indexing time, as a default. And can be overidden at query time.

1000 is the maximum.

In most cases, page/hitsPerPageis the recommended method for pagination. Check our our full discussion on pagination approaches.

Examples

Set default number of hits per page

<?php
$index->setSettings([
  'hitsPerPage' => 20
]);
index.set_settings({
  hitsPerPage: 20
})
index.setSettings({
  hitsPerPage: 20
});
index.setSettings({
    'hitsPerPage': 20
})
index.setSettings([
    "hitsPerPage": 20
])
index.setSettings(new JSONObject().put("hitsPerPage", 20));
index.SetSettings(
  JObject.Parse(@"{""hitsPerPage"":""20""}")
);
index.setSettings(
  new IndexSettings().setHitsPerPage(20)
);
res, err := index.SetSettings(algoliasearch.Map{
    "hitsPerPage": 20,
})
client.execute {
  changeSettings of "myIndex" `with` IndexSettings(
    hitsPerPage = Some(20)
  )
}
<?php
$results = $index->search('query', [
  'hitsPerPage' => 20
]);
results = index.search('query', {
  hitsPerPage: 20
})
index.search({
  query: 'query',
  hitsPerPage: 20
}).then(res => {
  // console.log(res);
});
results = index.search('query', {
    'hitsPerPage': 20
})
let query = Query(query: "query")
query.hitsPerPage = 20

index.search(query, completionHandler: { (res, error) in
    print(res)
})
index.search(new Query("query").setPage(0));
index.search(
  new Query("query").SetNbHitsPerPage(20)
)
index.search(
  new Query("query").setHitsPerPage(20)
);
res, err := index.Search("query", algoliasearch.Map{
    "hitsPerPage": 20,
})
client.execute {
  search into "myIndex" query Query(
    query = Some("query"),
    hitsPerPage = Some(20)
  )
}
Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala
Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala