示例#1
0
        public QueryResponse DoSearch(CourseQuery query)
        {
            //create response
            QueryResponse queryResponse = new QueryResponse();

            //save query
            queryResponse.OriginalQuery = query;

            //get solr
            ISolrOperations <Course> solr = _connection.GetSolrInstance();

            //query
            QueryOptions options = new QueryOptions()
            {
                Rows          = query.Rows,
                StartOrCursor = new StartOrCursor.Start(query.Start),
                Highlight     = Highlights.BuildParameters()
            };

            //execute the query
            ISolrQuery solrQuery = new SolrQuery(query.Query);
            SolrQueryResults <Course> solrResult = solr.Query(solrQuery, options);

            //Set response
            ResponseExtraction responseExtractions = new ResponseExtraction();

            responseExtractions.SetHeader(queryResponse, solrResult);
            responseExtractions.SetBody(queryResponse, solrResult);

            return(queryResponse);
        }
示例#2
0
        public QueryResponse DoSearch(MovieQuery query)
        {
            //Create an object to hold results
            FiltersFacets   filtersFacets   = new FiltersFacets();
            Highlights      highlights      = new Highlights();
            ExtraParameters extraParameters = new ExtraParameters();

            SolrQueryResults <Movie> solrResults;
            QueryResponse            queryResponse = new QueryResponse
            {
                //Echo back the original query
                OriginalQuery = query
            };

            //Get a connection
            ISolrOperations <Movie> solr         = connection.GetSolrInstance();
            QueryOptions            queryOptions = new QueryOptions
            {
                Rows          = query.Rows,
                StartOrCursor = new StartOrCursor.Start(query.Start),
                FilterQueries = filtersFacets.BuildFilterQueries(query),
                Facet         = filtersFacets.BuildFacets(),
                Highlight     = highlights.BuildHighlightParameters(),
                ExtraParams   = extraParameters.BuildExtraParameters()
            };

            //Execute the query
            ISolrQuery solrQuery = new SolrQuery(query.Query);

            solrResults = solr.Query(solrQuery, queryOptions);

            //Set response
            ResponseExtraction extractResponse = new ResponseExtraction();

            extractResponse.SetHeader(queryResponse, solrResults);
            extractResponse.SetBody(queryResponse, solrResults);
            extractResponse.SetSpellcheck(queryResponse, solrResults);
            extractResponse.SetFacets(queryResponse, solrResults);

            //Return response;
            return(queryResponse);
        }
示例#3
0
        public QueryResponse DoSearch(EhsQuery query)
        {
            FiltersFacets filtersFacets = new FiltersFacets();
            Highlights    highlights    = new Highlights();


            //Create an object to hold results
            SolrQueryResults <EHSDoc> solrResults;
            QueryResponse             queryResponse = new QueryResponse();

            //Echo back the original query
            queryResponse.QueryText = query;

            //Create method for increased readibility.
            //Move to some sort of application start or build eveuntally.
            bool initialize = Connection.Initialized;
            ISolrOperations <EHSDoc> solr = Connection.SolrOperations;

            QueryOptions queryOptions = new QueryOptions
            {
                Rows          = query.Rows,
                Facet         = filtersFacets.BuildFacets(),
                FilterQueries = filtersFacets.BuildFilterQueries(query),
                Highlight     = highlights.BuildHighlightParameters(),
            };

            //Execute the query
            ISolrQuery solrQuery = new SolrQuery(query.QueryText);

            solrResults = solr.Query(solrQuery, queryOptions);

            //Set response
            ResponseExtraction extractResponse = new ResponseExtraction();

            extractResponse.SetHeader(queryResponse, solrResults);
            extractResponse.SetBody(queryResponse, solrResults);
            extractResponse.SetFacets(queryResponse, solrResults);

            //Return response;
            return(queryResponse);
        }