Forum Discussion
Call "standard" search result page (or webpart) from custom query
- Apr 07, 2017You need to construct the KQL to pass to limit for what you need:
/_layouts/15/osssearchresults.aspx?u=https://..path-to-document-library&k=myterm prop1:propvalue
If you column with a property is a site column it will have generated an automatic managed property for you which you can query for. Say you have a text site column named "Foo", then the managed property would be named FooOWSTEXT, and you query would be:
/_layouts/15/osssearchresults.aspx?u=https://..path-to-document-library&k=myterm FooOWSTEXT:label
When I push the search button, this query is generated and fired:
https://blabla.sharepoint.com/_api/web/lists/getByTitle('Documents')/items?$select=FileLeafRef,FileRef,File_x0020_Type,Categorie,Label/Title&$expand=Label&$filter=Label/Title eq %27"+ inputLabel +"%27&rowlimit=500
Inputlabel is the result from my dropdown.
Would be something like: "Currentsite/result.aspx?k="myquery" ?
Is it also possible to stay on the current site, without a complete page refresh?
The value of the "k" querystring parameter is read by the Search Results Web Part. In other words, if you put a Search Results Web Part on your page you should be able to start querying by appending the k Query String parameter with your search term value to the URL and see the results. You can use JavaScript to request a specific page (or the page you're currently on) appending the required querystring parameter.
- Mike JansenApr 05, 2017Iron ContributorI'll give it a try.
Let you know the result.
Thanks, Mike- Mike JansenApr 06, 2017Iron Contributor
I tried a, long, night to get it running. But no luck.
I try to manipulate the search URL. But it look like is is not possible with only the "k=" parameter. As far as I can see I can only pass a search keyword. But I need to pass, a keyword, a document library and a property of the documents.
"Show all documents(from document library X) with keyword "Dog" where label is some lookupvalue"
The search api query I use now is:
https://blabla.sharepoint.com//_api/web/lists/getByTitle('Documents')/items?$select=FileLeafRef,FileRef,File_x0020_Type,Categorie,Label/Title&$expand=Label&$filter=Label/Title eq %27"+ inputLabel +"%27&rowlimit=500All I want is to pass the results to a standaard search webpart or page.
- Mikael SvensonApr 07, 2017Iron ContributorYou need to construct the KQL to pass to limit for what you need:
/_layouts/15/osssearchresults.aspx?u=https://..path-to-document-library&k=myterm prop1:propvalue
If you column with a property is a site column it will have generated an automatic managed property for you which you can query for. Say you have a text site column named "Foo", then the managed property would be named FooOWSTEXT, and you query would be:
/_layouts/15/osssearchresults.aspx?u=https://..path-to-document-library&k=myterm FooOWSTEXT:label