Retrieve Snippet for attribute but not entire attribute

I have an index that has a really large attribute and I do not want to retrieve the entire attribute when I query the data. The use case of my application does not need the entire attribute, just a small snippet of the portion of the attribute that matches. Is there any way to retrieve the snippet of the attribute and not retrieve the entire attribute as well?

Thanks!

Hi @nrwebb,

Thanks for contacting Algolia. I appreciate the question, unfortunately this is not possible. The entire searchable attribute will be returned.

Best,

Hi David! I think I actually found a way to do it. I just need to remove the attribute from the attributesToReceive and then make sure it is searchable and snippetable. Hope this helps someone else!

1 Like

Aah, interesting! Leveraging attributesToRetrieve - so for yours you might exclude the one that you only want to snippet:

index.setSettings({
  attributesToRetrieve: [
    '*',
    '-mySnippetOnlyAttr'
  ]
});

Thanks for sharing!