Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }