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); }
public static IQueryResultProcessor SelectQueryResultProcessor(ResultProcessor type, SearchSPIndexCmdlet cmdlet, SearchQueryRequest searchQueryRequest) { IQueryResultProcessor qrp = null; switch (type) { case ResultProcessor.Raw: qrp = new RawResultProcessor(cmdlet); break; case ResultProcessor.Primary: qrp = new PrimaryResultsResultProcessor(cmdlet); break; case ResultProcessor.All: qrp = new AllResultsResultProcessor(cmdlet); break; case ResultProcessor.Refiners: qrp = new RefinerResultProcessor(cmdlet); break; case ResultProcessor.Basic: qrp = new BasicResultProcessor(cmdlet); break; case ResultProcessor.RankXML: qrp = new RankXMLResultProcessor(cmdlet); break; case ResultProcessor.RankDetail: qrp = new RankDetailResultProcessor(cmdlet); break; case ResultProcessor.ExplainRank: qrp = new ExplainRankResultProcessor(cmdlet); break; case ResultProcessor.RankContribution: qrp = new RankContributionresultProcessor(cmdlet); break; case ResultProcessor.AllProperties: qrp = new AllPropertiesResultProcessor(cmdlet, searchQueryRequest); break; case ResultProcessor.AllPropertiesInline: qrp = new AllPropertiesInlineResultProcessor(cmdlet, searchQueryRequest); break; default: throw new NotImplementedException("No result processor match " + type); } return(qrp); }
/// <summary> /// Creates a new Mapping Engine. /// The connection wont be closed by the mapping engine. /// /// </summary> /// <param name="connection">connection which is used to query the database</param> /// <param name="root">mapped object which is the root</param> public MappingEngine(IDbConnection connection, MappedObject root) { if (connection == null) { throw new ArgumentNullException("connection cant be null"); } if (root == null) { throw new ArgumentNullException("mappedObject cant be null"); } this.connection = connection; this.root = root; commandManager = new DefaultCommandManager(connection); standardQueryResultProcessor = new StandardQueryResultProcessor(); nestedQueryResultProcessor = new NestedQueryResultProcessor(); }
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); }
public void Add(QueryExpression query, IQueryResultProcessor resultSetProcessor) { _queries.Add(new QueryInfo(query, resultSetProcessor)); }
public QueryInfo(QueryExpression query, IQueryResultProcessor resultProcessor) : this(query, true) { ResultSetProcessor = resultProcessor; }