Showing posts with label Query. Show all posts
Showing posts with label Query. Show all posts

Monday, August 10, 2020

Search Options for Microsoft Stream

The Issue

If you've tried out Microsoft Stream within your Office 365 tenancy, then chances are you've begun to realize that its searching capabilities leave much to be desired (they stink). To be fair, the app offers searching across all videos, but only finds text matches and orders results by most views. This can be somewhat mitigated by organizing the videos into channels and then searching within, but again, results are surfaced by most views, rather than relevance to the search keywords. Do I expect YouTube class results? Certainly not, but it's next to impossible to find meaningful results without refiners who at least some basic algorithmic factors to match results. In my tests, results with vague transcript matches and more views were weighted higher than full text match results in the title, description, and transcript, but had no views, due to the poor searching mechanism. Every "discovery" feature of MS stream is focused on overall viewership, versus quality of metadata or interest. One more shortcoming is that the search results cannot be crawled or queried from SharePoint Online Search. More can be read in the official documentation:

SEARCHING: https://docs.microsoft.com/en-us/stream/portal-search-browse-filter

EXPLORING: https://docs.microsoft.com/en-us/stream/portal-explore-content 


One Workaround

A very simple approach, is to use an html input element to collect search term and apply simple javascript to concatenate a string from a search value, pointing to https://web.microsoftstream.com/browse and using the query string parameter "q" to set the search value. I tried using the built in SharePoint search web parts, but it always appends a extra "k" query string parameter, which breaks the string handed off to Stream. This works as a basic example, but again, is limited by Stream's lack of intelligence search options and compiling results based on popularity, rather then relation to the search terms. On the plus side, this does allow a formulated query to passed from SharePoint Online to Stream. See the following code example for this idea (which monitors keystrokes for a "return" or "enter" key press to execute the inline script):

<input type="text" onkeyup="javascript: if(event.keyCode === 13)window.open('https://web.microsoftstream.com/browse?q='+this.value,'openSearch');" />


Another Take

I looked for a simple way to use the same kind of search by query string parameter in the channel search, but it looks that Microsoft is using an asynchronous API call for channel search, different from result filtering by query string as with the general video search. In looking at it briefly, it seemed to be a JSON result that could be parsed and styled with a little work, but I didn't dig much further as the results will again be fueled by popularity.  


A Mix of Services

In the case of what I was designing, I found I could achieve the best of all my requirements for using Stream to buffer video, then using a SharePoint Online Asset Library, using the embedded video option, to create index-able records with metadata that would be accessible to Search. In this way, I can build pages and content around those results, using Stream only as host service, rather than a content platform. This proved to be the most effective of everything tried. 

Have you tried to tackle this challenge as well? What kinds of solutions did you try out? 

Wednesday, November 25, 2015

Using SPServices to Query Subsites

SPServices is really a fantastic JQuery library that is specifically designed to embrace SharePoint. My initial brush with it was positive, but then quickly put me into a difficult place to find the answer to (what I thought was) a simple question:

Can SPServices query subsite lists? 

Quick searches insisted the answer was "Yes!", but code suggestions did not prove successful. I found with some trial and error that I could query localized lists (Lists in the current site level) without any issue, but when adjusting the url for subsite lists, I would receive the xml response "Site does not exist".

To explain my scenario, I was attempting to use SPServices to reference a specific list and return a specific field from each submitted item. I narrowed my troubles to a single attribute called "webURL". Many forums (including the documentation I believe) shows the property as "webUrl", which does work and return localized list data. But only "webURL" (notice the case difference) returns data from subsite lists. After making this small, but significant discovery, my code took off!

Hope this helps someone!

<script type="text/javascript" src="jquery-1.7.2.js"></script>

<script type="text/javascript" src="jquery.SPServices-0.7.2.js"></script>



//THIS WOUlD NEED TO BE WRAPPED IN EITHER A FUNCTION OR HANDLER  

$().SPServices({

                operation: "GetListItems",

                async: false,

                listName: "[List Name]",

                webURL: "http://[site]/[subsite]",

                CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",

                completefunc: function(xData, Status) {


            //THIS IS A HANDY WAY TO CHECK THE RESPONSE AND CLARIFY FIELDS

                //alert(xData.responseText);

                      

                      $(xData.responseXML).find("z\\:row").each(function() {

                      

        var liHtml = "<li>" + $(this).attr("ows_field15") + "</li>";

        $("#taskItems").append(liHtml);

        

         });

        }

                                                

});

   

}

 

<ul id="taskItems" />