I want to create one page or document library where can I perform search.
Suppose user hit the Url like http://mysite/doclibname/filestartname
that time on my page show only filestartname files. How can I do?
-
hi, Please correct me If my understanding is wrong ? You are asking that you want to create a page where the search results has to show, when a user type the text on search text box and hit the search button or press enter. it has to redirected to your page and you want to display the results in your own page ?– Suresh BolineniFeb 22, 2017 at 11:44
-
No I want to give user link like mysite/doclibname/filestartname when user click on this i want to show only this document on my page.– AdminFeb 22, 2017 at 11:47
-
it is not clear still can you please eloberate with little more explanation– Suresh BolineniFeb 22, 2017 at 11:51
-
<a href="mysite/doclibname/filestartname"> Click Here to open File</a> This is my code when user click on this link open my document library and show only this "filestartname" document.– AdminFeb 22, 2017 at 12:00
1 Answer
Please check this it might helpful to you.
- You create a result source in Site search settings for this go to Site Settings -> Search -> result source -> create new result source
- type the name of the source and click on "Launch Query builder"
Paste the Query which is given here
{QueryString.MyParameter1} {?owstaxIdMetadataAllTagsInfo:{Tag}} (FileExtension:doc OR FileExtension:docx OR FileExtension:xls OR FileExtension:xlsx OR FileExtension:ppt OR FileExtension:pptx OR FileExtension:pdf) (IsDocument:"True" OR contentclass:"STS_ListItem")
click on Ok and Save button to create result source
- you create a web part page like "Result.aspx" in page library
- insert search result webpart and go to Webpart Properties and select the result source and click on apply and ok to save the changes
after that you can specify url for anchor tag "/Pages/Search.aspx?MyParameter1=Title:filestartname*" with query string. in your case
<a href="mysite/Pages/Search.aspx?MyParameter1=Title:filestartname*">; Click Here to open File</a>
it automatically filter the result and show based on "filestartname".
Please check and let me know if you need any additional information.
-
Search Preview test screen I get result but when hit he url that time not work.– AdminFeb 22, 2017 at 14:31
-
If you keep this {QueryString.MyParameter1} and in test result preview you cannot see the results as the query text comes from query string. You just save and pass manually in the url and you can the results on the page directly. Feb 23, 2017 at 5:11
-
Yes bro I pass the value in URL but result not display. href="mysite/Pages/Search.aspx?MyParameter1=filestartname* When i pass this URL result display but when i pass url href="mysite/Pages/Search.aspx?MyParameter1=Title:filestartname* that time not display. why?– AdminFeb 23, 2017 at 5:23
-
May be Title(Title:filestartname*) field is blank for all documents in library. you try with other fields present in library which has data like author. author:admin* Feb 23, 2017 at 5:30
-
I try other fields but not work this "MyParameter1=Title:filestartname" But when I try this MyParameter1=filestartname* that time filter– AdminFeb 23, 2017 at 5:41