SharePoint Content Search
Content searching in documents write this code snippet in ASP.NET WCF service.
public MethodResponse<ClientResult<ResultTableCollection>> SearchDocuments(string text, string token) { MethodResponse<ClientResult<ResultTableCollection>> response = new MethodResponse<ClientResult<ResultTableCollection>>(); UserCredential userCredential = new UserCredential(); try { userCredential = VerifyToken(token); if (userCredential != null) { _ctx = GetClientContext(userCredential); if (_ctx != null) { KeywordQuery keywordQuery = new KeywordQuery(_ctx); keywordQuery.QueryText = Convert.ToString(text); SearchExecutor searchExecutor = new SearchExecutor(_ctx); ClientResult<ResultTableCollection> results = searchExecutor.ExecuteQuery(keywordQuery); _ctx.ExecuteQuery(); response.ErrorCode = "200"; response.ErrorDescription = "No Error"; response.Response = results; } } } catch (Exception ex) { response.ErrorCode = "400"; response.ErrorDescription = ex.Message; response.Response = null; } return response; }
Comments
Post a Comment