Search for folder results are null even though match is exact

  • 1
  • Problem
  • Updated 1 year ago
I'm using the C# SDK to query ShareFile for a specific client folder as such:

var searchResults = await sfClient.Items.Search(App.selectedclient).ExecuteAsync();
foreach (SearchResult result in searchResults.Results)

The folder name is a mixture of letters and numbers following pattern (# ## Aaaaaa Aaaaa - AA).

The search results are NULL every time; i'm having no other issues with any other searches with all letters or with consecutive numbers and letters (for example, ### Aaaaaaaaa - AA).  Seems like something about the space between the numbers in the search string is causing problems.  Please help.
Photo of Eric

Eric

  • 4 Posts
  • 2 Reply Likes
  • frustrated

Posted 1 year ago

  • 1
Photo of Andy Berryman

Andy Berryman, Software Engineer

  • 27 Posts
  • 7 Reply Likes
Can you try quoting the value that you are searching for to see if it changes the results?  So instead of ... [# ## Aaaaaa Aaaaa - AA] ... you send in ... ['# ## Aaaaaa Aaaaa - AA']
Photo of Eric

Eric

  • 4 Posts
  • 2 Reply Likes
Results are still null after adding single quotes around the search string

If I remove the space between the numbers it returns the folder correctly, but this isn't an option as our client names have to match exactly.
Photo of Jeremy Rowe

Jeremy Rowe

  • 5 Posts
  • 1 Reply Like
Can you supply a code snippet of the call you're making (please remove any sensitive data) so that we can dive in deeper?
Photo of Eric

Eric

  • 4 Posts
  • 2 Reply Likes
To recap...

 public static async Task<Folder> LoadFolderAndChildren(ShareFileClient sfClient)
        {
            //Search for the client folder
            var searchResults = await sfClient.Items.Search(App.selectedclient).ExecuteAsync();
            foreach (SearchResult result in searchResults.Results)

App.selectedclient is a string variable that represents the precise client name as it appears in ShareFile.  The only client folder i'm not able to return in the searchResults object has a name with a pattern of "# ## Aaaaaa Aaaaa - AA".  If I change their name to lead with "###" instead of "# ##" it returns fine.


Photo of Jeremy Rowe

Jeremy Rowe

  • 5 Posts
  • 1 Reply Like
Thanks for the info, I'll dive in and get back to you.
Photo of Jeremy Rowe

Jeremy Rowe

  • 5 Posts
  • 1 Reply Like
IQuery query = client.Items.AdvancedSearch( new SearchQuery { Query = new Query { ItemNameOnly = true, SearchQuery = "# ## Aaaaaa Aaaaa - AA" } } );
Photo of Jeremy Rowe

Jeremy Rowe

  • 5 Posts
  • 1 Reply Like
If you use the advance search endpoint, setting to name only, it should work for you. Let me know if it doesn't.
Photo of Eric

Eric

  • 4 Posts
  • 2 Reply Likes
Works perfectly; thanks a bunch!
Photo of Jeremy Rowe

Jeremy Rowe

  • 5 Posts
  • 1 Reply Like
No problem!