Пример #1
0
        /// <summary>
        /// Performs a search against Azure Search using the parameters and allowed document keys.
        /// </summary>
        /// <param name="ecaSearchParameters">The eca search parameters.</param>
        /// <param name="allowedDocumentKeys">The document keys the search is allowed to include.</param>
        /// <returns>The search result.</returns>
        public async Task <DocumentSearchResponse <ECADocument> > SearchAsync(ECASearchParameters ecaSearchParameters, List <DocumentKey> allowedDocumentKeys)
        {
            var client     = GetClient();
            var parameters = GetSearchParameters(ecaSearchParameters, allowedDocumentKeys);
            var response   = await client.Documents.SearchAsync <ECADocument>(ecaSearchParameters.SearchTerm, parameters);

            return(response);
        }
Пример #2
0
        /// <summary>
        /// Performs a search against Azure Search using the parameters and allowed document keys.
        /// </summary>
        /// <param name="ecaSearchParameters">The eca search parameters.</param>
        /// <param name="allowedDocumentKeys">The document keys the search is allowed to include.</param>
        /// <returns>The search result.</returns>
        public DocumentSearchResponse <ECADocument> Search(ECASearchParameters ecaSearchParameters, List <DocumentKey> allowedDocumentKeys)
        {
            var client     = GetClient();
            var parameters = GetSearchParameters(ecaSearchParameters, allowedDocumentKeys);
            var response   = client.Documents.Search <ECADocument>(ecaSearchParameters.SearchTerm, parameters);

            return(response);
        }
Пример #3
0
        /// <summary>
        /// Returns azure search parameters given the eca search parameters and all allowed document keys.
        /// </summary>
        /// <param name="ecaSearchParameters">The eca search parameters.</param>
        /// <param name="allowedDocumentKeys">The document keys that a search is allowed to include.</param>
        /// <returns>The SearchParameters instance for an azure search.</returns>
        public SearchParameters GetSearchParameters(ECASearchParameters ecaSearchParameters, List <DocumentKey> allowedDocumentKeys)
        {
            List <string> highlightFields = null;

            if (ecaSearchParameters.SelectFields != null)
            {
                highlightFields = GetFields()
                                  .Where(x => x.IsSearchable && ecaSearchParameters.SelectFields.Select(f => f.ToLower()).ToList().Contains(x.Name.ToLower()))
                                  .Select(x => x.Name).ToList();
            }
            var searchParameters = new SearchParameters
            {
                Skip   = ecaSearchParameters.Start,
                Top    = ecaSearchParameters.Limit,
                Filter = ecaSearchParameters.Filter,
                IncludeTotalResultCount = true,
            };

            if (ecaSearchParameters.HighlightPreTag != null && ecaSearchParameters.HighlightPostTag != null)
            {
                searchParameters.HighlightPostTag = ecaSearchParameters.HighlightPostTag;
                searchParameters.HighlightPreTag  = ecaSearchParameters.HighlightPreTag;
            }
            if (highlightFields != null && highlightFields.Count > 0)
            {
                searchParameters.HighlightFields = highlightFields;
            }
            if (ecaSearchParameters.Facets != null)
            {
                var distinctFacets = ecaSearchParameters.Facets.Distinct().ToList();
                searchParameters.Facets = distinctFacets;
            }
            if (ecaSearchParameters.SelectFields != null)
            {
                var distinctFields = ecaSearchParameters.SelectFields.Distinct().ToList();
                searchParameters.Select = distinctFields;
            }
            return(searchParameters);
        }
Пример #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="searchParameters"></param>
 /// <param name="allowedDocumentKeys"></param>
 /// <returns></returns>
 public Task <DocumentSearchResponse <ECADocument> > SearchAsync(ECASearchParameters searchParameters, List <DocumentKey> allowedDocumentKeys)
 {
     Contract.Requires(searchParameters != null, "The search parameters must not be null.");
     return(Task.FromResult <DocumentSearchResponse <ECADocument> >(null));
 }
Пример #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="searchParameters"></param>
 /// <param name="allowedDocumentKeys"></param>
 /// <returns></returns>
 public DocumentSearchResponse <ECADocument> Search(ECASearchParameters searchParameters, List <DocumentKey> allowedDocumentKeys)
 {
     Contract.Requires(searchParameters != null, "The search parameters must not be null.");
     return(null);
 }