开发者

How to use the XML result of SolrNet in my ASP.NET code behind

开发者 https://www.devze.com 2023-04-10 11:42 出处:网络
I found http://code.google.com/p/solrnet/wiki/Stats link. But I cannot understand it properly. I want to use a (min,max) kind of function with a Solr query.

I found http://code.google.com/p/solrnet/wiki/Stats link. But I cannot understand it properly. I want to use a (min,max) kind of function with a Solr query.

My query (display min, max and average price of R开发者_JAVA技巧ound shape and color D and clarity FL and caratweight. (This query will be generated 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 the following URL, I am getting min, max, count and mean.. Things like those I want. But it's in XML format. Now I want to customize. 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

What should I do?


Load the XML result into XML document and use XPath to access get the value of desired elements.

var xmlDocument = new XmlDocument();
xmlDocument.Load(solrXmlResult);
var mean = double.Parse(xmlDocument.DocumentElement.GetElementByTagName("//mean")[0].InnerText);
...

or based on your XML

var mean = double.Parse(
  xmlDocument.DocumentElement.GetElementByTagName(
    "//lst[@name=\"tag\"]/double[@name=\"min\"]"
  )[0].InnerText);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号