Level up your Box knowledge with brand new learning paths on Box University. Visit training.box.com to get started

Box API Search

New post

Comments

8 comments

  • monte1

    If the file is OCR'd perhaps you can search by information within the document as opposed to the file name. It is unlikley that the file is eliminated from the search index.

    0
    Comment actions Permalink
  • HungryX2Hippo

    Thanks for your suggestion. It's a csv datatable. The contents of the data are not unique enough to search the content, but I appreciate the suggestion!

     

    0
    Comment actions Permalink
  • Murtza

     Have you tried an exact search to find the file? You can run an exact match search by putting your query in quotes and escaping the quotes with backslashes. Below is an example using our Ruby SDK. 

     

    require 'boxr'
    
    client = Boxr::Client.new('DEVELOPER_TOKEN')
    search_query = "\"CF34-10 2017 FM CASH Template \""
    search_results = client.search(query=search_query)
    puts search_results

     

     

    0
    Comment actions Permalink
  • ondgat

    Hi Murtza,

    do you know how to use the exact search in .NET Box.V2.SDK ?

    This is my code, which does not work (I get similar results and the exact match is nowhere near the top).

     

    var queryResult = await AdminClient.SearchManager.QueryAsync("\""+FolderName+"\"",
    limit: 200, offset: 0, scope: "enterprise_content", type: "folder",
    ancestorFolderIds: new string[] { ParentFolderId },
    contentTypes: new string[] { "name" });

     

    Furthermore, as you can see I have the ParentFolderId, but I am still using the SearchManager inside this folder instead of retrieving the sub-folders via FoldersManager.GetFolderItemsAsync() and filtering them on the client, because there is 168 thousand sub-folders, so the query itself takes 5 minutes.

    It would be great if the SearchManager.QueryAsync() function provided an argument to specify that I want the search to only look at the single (top) level of the ancestorFolderIds and not traverse it's sub-folders. This would significantly reduce the number of returned results, which are usually high due to folder names do not need to be unique across vertical depth of the folder structure.

     

    Thanks in advance for any answer!

    0
    Comment actions Permalink
  • WMF

    I'm able to get the exact match work with the same way you have coded, the only difference you have is type set to folder vs i have it set to files. You could try to set to type to file and see if there is any difference in your result. Good luck!

    0
    Comment actions Permalink
  • WMF

    One thing i have seen with the type folder search, API returns 0, if there are no files in the folder but even if the folder exists:

    BoxCollection destinationBoxFolder = await client.SearchManager.QueryAsync(folderName, ancestorFolderIds: new List() { DestinationFolder },type:"folder");

    0
    Comment actions Permalink
  • dyndev

    Noticed the same thing, if folder has no files then search returns no folders even if they are there. This is a major bug and I hope someone from Box is looking at these boards.

    0
    Comment actions Permalink
  • Sai Vamsi

    How to make query optional here, I want to invoke the call like below, but API throwing bad request error.

     

    var items = await client.SearchManager.QueryAsync(query:"", createdAfter: StartDate, createdBefore: EndDate, updatedAfter: StartDate, updatedBefore: EndDate);
     
     
    I want filter the data by on Dates, not with query.
     
    Thanks
    0
    Comment actions Permalink

Please sign in to leave a comment.