Closed arhoy closed 4 years ago
the hits per page is supposed to go in the settings key (in each query), does that fix it for you? The hitsPerPage where you put it isn't an option :)
I am not sure what you mean by settings key in each query
Do you have a code example or screenshot I can follow?
Thank you. Currently I am limiting like so, but I not sure if it is best practice
const ProductSearchPreview = ({ hit }) => {
if (hit && hit.__position <= 9) {
return (
<Container>
<CustomLink to={`/product/${hit.handle}`}>
<h4>{hit.title}</h4>
</CustomLink>
</Container>
);
} else {
return null;
}
};
I would prefer to limit it in some settings to limit my algolia index usage.
const queries = [
{
query: myQuery,
transformer: ({ data }) => data.allSitePage.edges.map(({ node }) => node), // optional
indexName: 'index name to target', // overrides main index name, optional
settings: {
// optional, any index settings
hitsPerPage: 9
},
},
];
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-algolia`,
options: {
appId: process.env.ALGOLIA_APP_ID,
apiKey: process.env.ALGOLIA_API_KEY,
indexName: process.env.ALGOLIA_INDEX_NAME, // for all queries
queries,
chunkSize: 10000, // default: 1000
},
},
],
};
OR in the frontend:
<Configure hitsPerPage={9} />
Thank you that is very helpful!
I am trying to limit the amount of hits or search results that algolia returns. I thought I could do the following inside the gatsby config.js file to limit the results to 8.
However, reducing that number does not seem to be doing anything. Am I missing something?