Beispiel #1
0
        public ResultTableCollection ExecuteSearch(ClientContext context, Guid webId, Guid siteId)
        {
            SearchExecutor searchExecutor = new SearchExecutor(context);
            KeywordQuery   keywordQuery   = SharepointCsomProvider.GetKeywordQuery(webId, siteId, context);
            ClientResult <ResultTableCollection> clientResult = searchExecutor.ExecuteQuery(keywordQuery);

            context.ExecuteQuery();
            return(clientResult.Value);
        }
Beispiel #2
0
        public ResultTableCollection ExecuteSearch(ClientContext context, string location, bool searchOnlySiteCollection)
        {
            SearchExecutor searchExecutor = new SearchExecutor(context);
            KeywordQuery   keywordQuery   = searchOnlySiteCollection ? SharepointCsomProvider.GetKeywordQueryForSiteCollectionOnly(location, context) : SharepointCsomProvider.GetKeywordQuery(location, context);
            ClientResult <ResultTableCollection> clientResult = searchExecutor.ExecuteQuery(keywordQuery);

            context.ExecuteQuery();
            return(clientResult.Value);
        }
Beispiel #3
0
        private static KeywordQuery GetKeywordQueryForSiteCollectionOnly(string location, ClientContext context)
        {
            KeywordQuery keywordQuery = new KeywordQuery(context);

            keywordQuery.QueryText = string.Format(CultureInfo.InvariantCulture, "Path:\"{0}\" AND contentclass=\"STS_Site\"", new object[]
            {
                location
            });
            keywordQuery.RowLimit = 2;
            SharepointCsomProvider.PopulateQueryDefaults(keywordQuery);
            return(keywordQuery);
        }
Beispiel #4
0
        private static KeywordQuery GetKeywordQuery(Guid webId, Guid siteId, ClientContext context)
        {
            KeywordQuery keywordQuery = new KeywordQuery(context);

            keywordQuery.RowLimit  = 1;
            keywordQuery.QueryText = string.Format(CultureInfo.InvariantCulture, "SiteId:\"{0}\" AND WebId:\"{1}\" AND (contentclass=\"STS_Web\" OR contentclass=\"STS_Site\")", new object[]
            {
                siteId.ToString("D"),
                webId.ToString("D")
            });
            keywordQuery.SelectProperties.Add("contentclass");
            keywordQuery.SelectProperties.Add("Path");
            keywordQuery.SelectProperties.Add("Title");
            SharepointCsomProvider.PopulateQueryDefaults(keywordQuery);
            return(keywordQuery);
        }
Beispiel #5
0
        private static KeywordQuery GetKeywordQuery(string location, ClientRuntimeContext context)
        {
            KeywordQuery keywordQuery = new KeywordQuery(context);

            keywordQuery.QueryText = string.Format(CultureInfo.InvariantCulture, "Path=\"{0}\"", new object[]
            {
                location
            });
            keywordQuery.RowLimit = 5;
            keywordQuery.SelectProperties.Add("WebId");
            keywordQuery.SelectProperties.Add("SiteId");
            keywordQuery.SelectProperties.Add("contentclass");
            keywordQuery.SelectProperties.Add("Path");
            keywordQuery.SelectProperties.Add("Title");
            SharepointCsomProvider.PopulateQueryDefaults(keywordQuery);
            return(keywordQuery);
        }