public SearchResult Search(SearchParameters parameters)
        {
            ISolrQuery query = parameters.BuildQuery();

            try
            {
                SolrQueryResults <MetadataIndexDoc> queryResults = _solrInstance.Query(query, new QueryOptions
                {
                    //WMS lag skal få redusert sin boost
                    FilterQueries = parameters.BuildFilterQueries(),
                    OrderBy       = parameters.OrderBy(),
                    Rows          = parameters.Limit,
                    Start         = parameters.Offset - 1, //solr is zero-based - we use one-based indexing in api
                    Facet         = parameters.BuildFacetParameters(),
                    Fields        = new[] { "uuid", "title", "title_en", "abstract", "purpose", "type", "theme", "organization", "organization_en", "organization_seo_lowercase", "organization_shortname", "placegroups", "organizationgroup",
                                            "topic_category", "organization_logo_url", "thumbnail_url", "distribution_url", "distribution_protocol", "distribution_name", "product_page_url", "date_published", "date_updated", "nationalinitiative",
                                            "score", "ServiceDistributionProtocolForDataset", "ServiceDistributionUrlForDataset", "ServiceDistributionNameForDataset", "DistributionProtocols", "legend_description_url", "product_sheet_url", "product_specification_url", "area", "datasetservice", "popularMetadata", "bundle", "servicelayers", "accessconstraint", "servicedataset", "otherconstraintsaccess", "dataaccess", "ServiceDistributionUuidForDataset", "ServiceDistributionAccessConstraint", "parentidentifier", "distributions" }
                    //ExtraParams = new Dictionary<string, string> {
                    //    {"q", ""}
                    //}
                });

                return(CreateSearchResults(queryResults, parameters));
            }
            catch (Exception ex)
            {
                Log.Error("Error in search", ex);

                return(CreateSearchResults(null, parameters));
            }
        }
        public SearchResult CreateSearchResults(SolrQueryResults <MetadataIndexDoc> queryResults, SearchParameters parameters)
        {
            List <SearchResultItem> items = ParseResultDocuments(queryResults);

            List <Facet> facets       = ParseFacetResults(queryResults);
            SearchResult searchResult = new SearchResult
            {
                Items  = items,
                Facets = facets,
                Limit  = parameters.Limit,
                Offset = parameters.Offset,
                Type   = GetType(queryResults)
            };

            if (queryResults != null)
            {
                searchResult.NumFound = queryResults.NumFound;
            }
            return(searchResult);
        }