string username = "***********"; string pwd = "*********"; string siteURL = "**********"; ClientContext context = new ClientContext(siteURL); Web web = context.Web; SecureString pass = new SecureString(); foreach (char c in pwd.ToCharArray()) pass.AppendChar(c); context.Credentials = new SharePointOnlineCredentials(username, passWord); try { KeywordQuery query = new KeywordQuery(context); query.QueryText = "ContentType:Factura AND PrecoOWSCURR>10000"; query.RowLimit = 10; query.RowsPerPage = 10; SearchExecutor search = new SearchExecutor(context); ClientResult<ResultTableCollection> results = search.ExecuteQuery(query); context.ExecuteQuery(); foreach (var resultRow in results.Value[0].ResultRows) { Console.WriteLine("{0}", resultRow["Title"]); } } catch (Exception e) { Console.WriteLine(e.ToString()); Console.ReadKey(); }
If you are searching through AppOnly Context, that app should have Search permission. This bit got me for couple of hours.
My bad we cant do keyword search through apponly context unless we give tenant full control to app