SharePoint Library Search Archives : Binary Bits https://blog.binarybits.net/tag/sharepoint-library-search/ Bits & Pieces - A blog by Kannan Balasubramanian Sun, 12 Aug 2012 07:00:25 +0000 en-GB hourly 1 https://wordpress.org/?v=6.5.3 Using SharePoint 2010’s OOB search result to search in a particular library https://blog.binarybits.net/using-sharepoint-2010s-oob-search-result-to-search-in-a-particular-library/ https://blog.binarybits.net/using-sharepoint-2010s-oob-search-result-to-search-in-a-particular-library/#respond Sun, 12 Aug 2012 06:32:33 +0000 https://blog.binarybits.net/?p=271 There was a requirement to have a search text box and a button in landing page and show OOB search result from a single document library. After doing some analysis on OOB search the following is the code which we came up with. The technique is use the query string with query items “k=query”, “cs=This […]

The post Using SharePoint 2010’s OOB search result to search in a particular library appeared first on Binary Bits.

]]>
There was a requirement to have a search text box and a button in landing page and show OOB search result from a single document library.

After doing some analysis on OOB search the following is the code which we came up with.

The technique is use the query string with query items “k=query”, “cs=This List” & “u=list’s absolute url”. Underlined items are the items which change dynamically.

http://server/sites/site/_layouts/OSSSearchResults.aspx?k=MyQuery&cs=This List&u=http://server/sites/site/MyLibrary

<div>
    <script type="text/javascript">
        function Search() {
            var libraryName = 'Library'; //Library Name            
            var url = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl; //http://server/sites/<sitecollection> orhttp://server/sites/<sitecollection>/site
            var searchUrl = url + '/_layouts/OSSSearchResults.aspx';

            var queryText = document.getElementById('querybox').value;
            var queryUrl = searchUrl + '?k=' + queryText + '&cs=This List&u=' + url + '/' + libraryName; //http://server/sites/<sitecollection>/_layouts/OSSSearchResults.aspx?k=<Query from input box>&cs=This List&u=http://server/sites/<site>/<Library Name>

            window.navigate(queryUrl);
            //alert(queryUrl);
        }            
    </script>
    <input id="querybox" name="querybox" />
    <input onclick="Search()" name="SearchInLibrary" value="Search In Adapter Document Library" type="button" />
</div>

The post Using SharePoint 2010’s OOB search result to search in a particular library appeared first on Binary Bits.

]]>
https://blog.binarybits.net/using-sharepoint-2010s-oob-search-result-to-search-in-a-particular-library/feed/ 0