hitsPerPage

Type: integer
Engine default: 20
Parameter syntax
'hitsPerPage' => number_of_hits
Parameter syntax
hitsPerPage: number_of_hits
Parameter syntax
hitsPerPage: number_of_hits
Parameter syntax
'hitsPerPage': number_of_hits
Parameter syntax
"hitsPerPage": number_of_hits
Parameter syntax
new JSONObject().put("hitsPerPage", number_of_hits)
Parameter syntax
dynamic settings = new JObject();
settings.hitsPerPage = number_of_hits;
Parameter syntax
.setHitsPerPage(number_of_hits)
Parameter syntax
"hitsPerPage": number_of_hits
Parameter syntax
hitsPerPage = Some(number_of_hits)

Can be used in these methods:
search, setSettings, browse, generateSecuredApiKey, addApiKey, updateApiKey search, set_settings, browse, generate_secured_api_key, add_api_key, update_api_key search, setSettings, browse, generateSecuredApiKey, addApiKey, updateApiKey search, set_settings, browse, generate_secured_api_key, add_api_key, update_api_key search, setSettings, browse searchAsync, setSettingsAsync, browseAsync Search, SetSettings, Browse, GenerateSecuredApiKey, AddApiKey, UpdateApiKey Search, setSettings, browse, generateSecuredApiKey, addApiKey, updateApiKey Search, SetSettings, Browse, GenerateSecuredAPIKey, AddAPIKey, UpdateAPIKey search, changeSettings, browse index, generateSecuredApiKey, add key, update key

About this parameter

Set the number of hits per page.

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


Usage notes:
  • This can be set at indexing time, as a default. And can be overridden at query time.

  • 1000 is the maximum.

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));
dynamic settings = new JObject();
settings.hitsPerPage = number_of_hits;

index.SetSettings(settings);
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' => 10
]);
results = index.search('query', {
  hitsPerPage: 10
})
index.search({
  query: 'query',
  hitsPerPage: 10
}).then(res => {
  // console.log(res);
});
results = index.search('query', {
  'hitsPerPage': 10
})
let query = Query(query: "query")
query.hitsPerPage = 10

index.search(query, completionHandler: { (res, error) in
  print(res)
})
index.search(
  new Query("query").setHitsPerPage(10)
);
index.search(
  new Query("query").SetNbHitsPerPage(10)
)
index.search(
  new Query("query").setHitsPerPage(10)
);
res, err := index.Search("query", algoliasearch.Map{
  "hitsPerPage": 10,
})
client.execute {
  search into "myIndex" query Query(
    query = Some("query"),
    hitsPerPage = Some(10)
  )
}
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