Search code examples
lucenesolraveragesolrnetmin

How to use Min,max and average with Solr.net


I found http://code.google.com/p/solrnet/wiki/Stats link.

But i cannot understand properly.

I want to use min,max kind of function with solr query.

My query(Display min, max and average price of Round shape and color D and clarity FL and caratweight.(This query will be genarated based on user's selection dynamically)

(Shape:"Round") AND (Color:"D") AND (Clarity:"FL") AND (CaratWeight:[1 TO 10])

But how can i use such kind of function and select specific column.

Now i am somewhat nearer...

By using following url, i am getting min,max,count and mean..things those i want. But its in xml format. Now i want to cusomize. I want to use this result in my asp.net code behind and want to do further computation.

http://localhost:8983/solr/coreMikisa/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on&stats=true&stats.field=Price 

So please reply.. how can i get???


Solution

  • http://localhost:8983/solr/coreMikisa/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on&stats=true&stats.field=Price 
    

    This can be expressed in SolrNet as:

    var statsParams = new StatsParameters();
    statsParams.AddField("Price");
    var results = solr.Query(SolrQuery.All, new QueryOptions {
        Rows = 10,
        Start = 0,
        Stats = statsParams
    });
    // use results.Stats...