Beispiel #1
0
        private int GetResults(SearchQueryRequest searchQueryRequest)
        {
            int  totalRows  = 0;
            bool keepTrying = true;

            // Pick default result processor
            if (!ResultProcessor.HasValue)      // user has not specified one
            {
                if (Refiners != null)
                {
                    ResultProcessor = PSSQT.ResultProcessor.Refiners;
                }
                else
                {
                    ResultProcessor = PSSQT.ResultProcessor.Primary;
                }

                WriteVerbose(String.Format("Using ResultProcessor {0}", Enum.GetName(typeof(ResultProcessor), ResultProcessor)));
            }

            IQueryResultProcessor queryResultProcessor = QueryResultProcessorFactory.SelectQueryResultProcessor(ResultProcessor.Value, this, searchQueryRequest);

            queryResultProcessor.Configure();    // May add required properties to retrieve (e.g. rankdetail etc.)

            while (keepTrying)
            {
                keepTrying = false;

                try
                {
                    var requestResponsePair = HttpRequestRunner.RunWebRequest(SetSelectProperties(searchQueryRequest));

                    var queryResults = requestResponsePair.GetResultItem();

                    totalRows = queryResults.PrimaryQueryResult.TotalRows;

                    queryResultProcessor.Process(queryResults);
                }
                catch (RankDetailTooManyResults ex)
                {
                    WriteWarning("More than 100 results in result set. Resubmitting query with filter to get RankDetail.");

                    searchQueryRequest.QueryText += ex.QueryFilter;
                    keepTrying = true;
                }
                catch (Exception ex)
                {
                    if (!queryResultProcessor.HandleException(ex))
                    {
                        throw;
                    }
                }
            }

            return(totalRows);
        }
Beispiel #2
0
        private int GetResults(SearchQueryRequest searchQueryRequest)
        {
            int  totalRows  = 0;
            bool keepTrying = true;

            IQueryResultProcessor queryResultProcessor = QueryResultProcessorFactory.SelectQueryResultProcessor(ResultProcessor, this);

            queryResultProcessor.Configure();    // May add required properties to retrieve (e.g. rankdetail etc.)

            while (keepTrying)
            {
                keepTrying = false;

                try
                {
                    var requestResponsePair = HttpRequestRunner.RunWebRequest(Up2Date(searchQueryRequest));

                    var queryResults = GetResultItem(requestResponsePair);

                    totalRows = queryResults.PrimaryQueryResult.TotalRows;

                    queryResultProcessor.Process(queryResults);
                }
                catch (RankDetailTooManyResults ex)
                {
                    WriteWarning("More than 100 results in result set. Resubmitting query with filter to get RankDetail.");

                    searchQueryRequest.QueryText += ex.QueryFilter;
                    keepTrying = true;
                }
                catch (Exception ex)
                {
                    if (!queryResultProcessor.HandleException(ex))
                    {
                        throw;
                    }
                }
            }

            return(totalRows);
        }