2

I'm looking to create a searchString for a search box that limits the results by a result source I've made.

Just like you would filter by a managed property. Eg.: {search center url}?k=Author:w16375.

But I can't seem to find anywhere that says how to enter a result source in the search box Query, like: {search center url}?k=ResultSource:Intranet.

Is this possible?

2
  • The query must be sent to a result page and a result webpart which need to have a result source specified.. is there any specific reason to do it like this instead of just using your Intranet result source? Commented Feb 10, 2016 at 11:33
  • I'd like to use the "Notify Me" feature on search. But if I set up a notify me on a specific result webpart, it still gives me e-mail containing all result sources. I've tried making a search Query with path:"http://..." and that Works, giving me only notifications from that URL. But it would be easier to do with a result source, IMHO.
    – thewolf
    Commented Feb 11, 2016 at 11:21

1 Answer 1

1

You have two options. One is to add a trigger term as part of the query to trigger a query rule which then changes the result source. This works as long as you don't have special characters in the query ()"-AND ANY etc.

The other option involves adding JavaScript to the page, and hook in to the add_queryIssuing event for the dataprovider of the webpart. Here you can change the result source you are targeting based on e.g. URL params. I have some code at https://github.com/wobba/Scripts/blob/master/mAdcOW.queryVariableInjector.ts which shows how to add code to hook in the code and event - allthough the sample does something different.

To make this work you need to set the web part in async mode so that the script can hook in before the first query is executed.

Hope this helps a bit on the way to excellence :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.