Getting all documents from a smart search index via API

Tom Troughton asked on May 17, 2016 14:53

I'm working with the smart search API and am stuck trying to find a way to return ALL documents from a given index.

I've found a couple of similar questions on here (like this and this) but neither answer seems to show how to return all documents.

Specifically what I want is to be able to set up a SearchParameters object with the usual environmental properties like culture, path, class names etc, but to not provide a search term. I'm finding that setting the SearchFor property to empty string or null both result in no documents being returned.

At the moment I'm implementing this in a way which feels very much like a hack by setting parameters.SearchFor = string.Format("documentculture:\"{0}\"", currentCultureCode) meaning I'm returning all documents for the current culture. There must be a more elegant way!

Correct Answer

Anton Grekhovodov answered on May 17, 2016 19:19

Hi Nat,

The smart search won't work, if SearchFor is empty. But if you don't want to use some hardcoded field name and find all documents, you can use *:* string for this property

1 votesVote for this answer Unmark Correct answer

Recent Answers

Tom Troughton answered on May 18, 2016 14:36

Thank you Anton, that works well.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.