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

Box Search returning all files - Node.js sdk

New post

Comments

1 comment

  • mwiller

     To try and get an exact match on a specific folder name, here's what I would suggest doing:

     

    var folderName = 'PUT_FOLDER_NAME_HERE';
    var parentFolderID = 'PUT_PARENT_FOLDER_ID_HERE';
    
    var searchOptions = {
        ancestor_folder_ids: parentFolderID,
        content_types: 'name',
        type: 'folder',
    };
    
    var query = '"' + folderName + '"'; // Use quoted query to get exact matches only
    
    var results = await client.search.query(query, searchOptions);
    var folder = results.entries.find(f => f.name === folderName && f.parent.id === parentFolderID);
    // `folder` should point to the exact folder you're looking for
    0
    Comment actions Permalink

Please sign in to leave a comment.