Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SolrNet Faceting question

Tags:

solr

solrnet

Using SolrNet for querying & faceting. I have a combination of int, tdate and string fields I would like to facet on. However I am unable to mix SolrFacetFieldQuery and SolrFacetQuery (for ranges) and SolrFacetDateQuery (for date ranges) in the same query. I get an error "no best type found for implicitly typed array". How should this best be handled? Clearly don't want to send multiple queries for getting the other facets.

I know this is something silly, but been vexing me....

      results = solr.Query(qry
      , new QueryOptions
      {
          Rows = 250,
          Facet = new FacetParameters
          {
              Queries = new[] 
                        {
                            new SolrFacetFieldQuery("Registry"),
                            new SolrFacetFieldQuery("Status"),
                            new SolrFacetFieldQuery("Type"),
                            //this is where it throws up "no best type found for implicty typed array"
                            new SolrFacetQuery(lessThan25),

                        }
          }

      });
like image 775
Mikos Avatar asked Dec 17 '25 19:12

Mikos


1 Answers

C# can't infer the common base type, so you have to be explicit about it when creating the array:

Queries = new ISolrFacetQuery[] {
   new SolrFacetFieldQuery("Registry"),
   new SolrFacetFieldQuery("Status"),
   new SolrFacetFieldQuery("Type"),
   new SolrFacetQuery(lessThan25),
}
like image 161
Mauricio Scheffer Avatar answered Dec 19 '25 22:12

Mauricio Scheffer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!