Retrieve Snippet for attribute but not entire attribute

snippet
#1

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!

#2

Hi @nrwebb,

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

Best,

#3

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
#4

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!