0

I have some custom columns on my site and I want to search keyword in that columns only. I am using CSOM. Can you please provide me solution for this problem. cuurent code which searches globally : KeywordQuery keywordQuery = new KeywordQuery(m_context); string Path = string.Empty; foreach ( string libraryName in libraryNames ) { Path += " Path:" + PluginConfigManager.siteUrl + "/" + System.Web.HttpUtility.UrlPathEncode(libraryName); } keywordQuery.QueryText = keyword + Path; SearchExecutor searchExecutor = new SearchExecutor(m_context); ClientResult results = searchExecutor.ExecuteQuery(keywordQuery); Logger.info("Executing ExecuteQuery for Search"); m_context.ExecuteQuery(); Thanks Sam

  • Which version of SharePoint? Or are you using SPO? Have you tried creating a Result Source for your site so you can add a Result Source attribute (SourceID) to your query? – Matthew McDermott Oct 28 '17 at 6:21
  • I am using SharePoint online, I want results from perticular library and also search should work on only specified columns. So how can i pass coulmns to search query? – Samadhan Oct 30 '17 at 12:09
0

Use KQL. I would use a Result Source to limit the results to the library. In fact, I would use a Content Type on the Library so that makes all of this SO much easier. You can use the Path Managed Property if you aren't going to use a content type. Like Path:"https://tenant.sharepoint.com/sites/site/library"

For the column use the Managed Property you created for the column MyManagedProperty:"My Query"

If you decide to use a Result Source you have to use the ID of the source not the name.

  • If I use the managed properties in search then it wont searches in pdfs and documents. I want to search in specified managed propertiers metadata and in content of pdfs, docuements too. – Samadhan Nov 1 '17 at 8:39
  • Include an OR clause and a free text component to you query and it will do that for you. Alternatively you can try using the Content or Body managed property. (I can't recall which worked for me.) – Matthew McDermott Nov 3 '17 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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