private IDictionary <string, QueryFilter> GetSubQueryString(ICollection <QueryFilter> filters)
        {
            int maxAllowedKeywords = Factory.Current.GetMaxAllowedKeywords(this.RecipientSession);

            if (filters.Count > maxAllowedKeywords)
            {
                throw new TooManyKeywordsException(filters.Count, maxAllowedKeywords);
            }
            int num = 0;
            Dictionary <string, QueryFilter> dictionary = new Dictionary <string, QueryFilter>(filters.Count);

            foreach (QueryFilter queryFilter in filters)
            {
                string      keywordPhrase = MailboxDiscoverySearch.GetKeywordPhrase(queryFilter, this.queryString, ref num);
                QueryFilter value         = queryFilter;
                if (this.propertyFilterQuery != null)
                {
                    value = new AndFilter(new QueryFilter[]
                    {
                        queryFilter,
                        this.propertyFilterQuery
                    });
                }
                if (!dictionary.ContainsKey(keywordPhrase))
                {
                    dictionary.Add(keywordPhrase, value);
                }
            }
            return(dictionary);
        }
Beispiel #2
0
 internal void GenerateSubQueryFilters(IRecipientSession recipientSession, IConfigurationSession configurationSession)
 {
     if (!string.IsNullOrEmpty(this.userQuery))
     {
         SearchMailboxCriteria.RecipientIdentityResolver recipientResolver = null;
         if (recipientSession != null)
         {
             recipientResolver = new SearchMailboxCriteria.RecipientIdentityResolver(recipientSession);
         }
         PolicyTagAdProvider policyTagProvider = null;
         if (configurationSession != null)
         {
             policyTagProvider = new PolicyTagAdProvider(configurationSession);
         }
         QueryFilter queryFilter = KqlParser.ParseAndBuildQuery(this.userQuery, KqlParser.ParseOption.ImplicitOr | KqlParser.ParseOption.UseCiKeywordOnly | KqlParser.ParseOption.DisablePrefixMatch | KqlParser.ParseOption.AllowShortWildcards | KqlParser.ParseOption.EDiscoveryMode, this.QueryCulture, RescopedAll.Default, recipientResolver, policyTagProvider);
         if (queryFilter == null)
         {
             throw new SearchQueryEmptyException();
         }
         ICollection <QueryFilter> collection = null;
         if (queryFilter != null && queryFilter.GetType() == typeof(OrFilter))
         {
             collection = AqsParser.FlattenQueryFilter(queryFilter);
         }
         if (collection != null && collection.Count > 1)
         {
             string      text         = this.searchQuery.Replace(this.userQuery, "");
             QueryFilter queryFilter2 = null;
             if (!string.IsNullOrEmpty(text))
             {
                 queryFilter2 = KqlParser.ParseAndBuildQuery(text, KqlParser.ParseOption.ImplicitOr | KqlParser.ParseOption.UseCiKeywordOnly | KqlParser.ParseOption.DisablePrefixMatch | KqlParser.ParseOption.AllowShortWildcards | KqlParser.ParseOption.EDiscoveryMode, this.QueryCulture, RescopedAll.Default, recipientResolver, policyTagProvider);
             }
             this.subfilters = new Dictionary <string, QueryFilter>(collection.Count);
             int num = 0;
             foreach (QueryFilter queryFilter3 in collection)
             {
                 string      keywordPhrase = MailboxDiscoverySearch.GetKeywordPhrase(queryFilter3, this.userQuery, ref num);
                 QueryFilter value;
                 if (queryFilter2 == null)
                 {
                     value = queryFilter3;
                 }
                 else
                 {
                     value = new AndFilter(new QueryFilter[]
                     {
                         queryFilter2,
                         queryFilter3
                     });
                 }
                 if (!this.subfilters.ContainsKey(keywordPhrase))
                 {
                     this.subfilters.Add(keywordPhrase, value);
                 }
             }
         }
     }
 }