MaxFacetHits is 50 but I'm still only getting 20

I have an ASP.NET Core application where I take my FAQ, break it up by question, and feed it to Algolia when the application starts; before I feed it in, however, I have a search to make sure I delete the ‘old’ documents to make way for the new (they are regularly updated and maintained so this comes in very handy).

My code looks like this:

var query = new Query("faq")
{
    RestrictSearchableAttributes = new List<string> {"slug"},
    Distinct = 0,
    MaxFacetHits = 50,
};
var items = index.Search<QuestionFile>(query);
log.LogInformation($"querying faq objects in index retrieved {items.Hits.Count} objects");
index.DeleteObjects(items.Hits.Select(s => s.slug));

The MaxFacetHits is set to 50 right now because it took me some time to fine tune the distinct property to return more than one value. I have 22 FAQ items to put in the index, but now matter what I try with MaxFacetHits it always gives me 20.

I’m about to register a bug in the GitHub repo but wanted to point this out to the group in case I might have missed something.

Thanks!

Hi @lucas.vogel!

MaxFacetHits is meant to be used with SearchForFacetValues and not with Search. I am sorry it’s misleading because both SearchForFacetValues and Search share the same Query object.

If you want to change the number of retrieved facet values for a regular search, see maxValuesPerFacet.

var query = new Query("faq")
{
    MaxValuesPerFacet = 50,
};