Office 365 & SharePoint Search / Development / Branding

Office graph search queries from within your SharePoint search center

on Oct 01, 2014 by Elio Struyf with 1 comment

Now that Delve is out, it is time to do some experiments with it. One of the things I wanted to test is if you can visualize results from Office Graph in your SharePoint search center.

You can of course query data on the Delve page itself, but most of our users always go to the default SharePoint search center to search for their content. By including an Office Graph search page to your SharePoint search center, your users do not have to leave your search center.

Solution

The solution is really easy. A couple of months ago I wrote a post about how you could dynamically change the result source in a search center (read more). This was achieved by overriding the default Srch.U.fillKeywordQuery function, manipulating some parameters and doing a call to the original fillKeywordQuery function.

The same approach can be used to query data from Office Graph. What you need to do is adding a query property to the submitted query. The property to add is the GraphQuery property, the property can contain various values (you can check them out on the following MSDN page). The GraphQuery property always needs an actor, the action is not always needed.

So what I wanted to achieve in my search center is to be able to add an actor ID and an action type.

Here is my code which you can add in a script editor web part on the search page.

The code gives you the following output:

Code output

Code output

Note: you can add the code in a script editor web part that you can place above the search box web part.

The textbox can be used to include the actor ID. If you leave it empty, it uses ME as value for the actor, so the query will be done in the context of the current user. In the dropdown you can select which action type you want to query from Office Graph.

Results

Default Office Graph query: ACTOR(ME)

Default Office Graph query: ACTOR(ME)

Office Graph query: ACTOR(ME, action:1020)

Office Graph query: ACTOR(ME, action:1020)

Important: refiners are not working, no refinement data gets returned.

Article comments