Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Two issues with KeywordQuery in Client with Managed CSOM

$
0
0

Hi All,

I’m new in SharePoint development and facing an issue for a week w/o any resolution. After extensive search, posting here with hope that some kind person will suggest what to do.

Background: we are developing a client desktop tool for sharepoint online site search. So we are using CSOM and KeywordQuery.

Issues:

  1.       keywordQuery.QueryText, can not search by custom column of document library. Suppose we have added two custom columns- “CaseNo” and “PurchaseAmount” in a document library called “DocLib1”. When using keywordQuery.QueryText = "caseno:123"; - it does not return anything
  2.       The CaseNo, PurchaseAmount fields are not returned in search result when search by keywordQuery.QueryText = "123";

So tried to add the property “keywordQuery.SelectProperties.Add("CaseNo ");” – it returns less number of column (32), but don’t return the CaseNo.

Giving code below:

using (ClientContext clientContext = new ClientContext("https://zzz"))

            {

                SecureString passWord = new SecureString();

                string pass = "zzzz";

                foreach (char c in pass.ToCharArray())

                    passWord.AppendChar(c);

                clientContext.Credentials = new SharePointOnlineCredentials("zzz.hotmail.com", passWord);

                KeywordQuery keywordQuery = new KeywordQuery(clientContext);

                 keywordQuery.RowLimit = 500;

                 keywordQuery.TrimDuplicates = true;

                 keywordQuery.SortList.Add("LastModifiedTime", Microsoft.SharePoint.Client.Search.Query.SortDirection.Descending);

                StringCollection selectProperties = keywordQuery.SelectProperties;

               

                keywordQuery.SelectProperties.Add("caseno");

                 keywordQuery.QueryText = "caseno:123"; 

               

                SearchExecutor searchExecutor = new SearchExecutor(clientContext);

                ClientResult<ResultTableCollection> results = searchExecutor.ExecuteQuery(keywordQuery);

                clientContext.ExecuteQuery();

                foreach (var resultRow in results.Value[0].ResultRows)

                {

                    Console.WriteLine("{0}: {1} ({2})", resultRow["Title"], resultRow["Path"], resultRow["Write"]);

                }

                Console.WriteLine("END");

                Console.ReadLine();

            }

Look forward your kind response with the answer

Regards,



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>