What steps will reproduce the problem?
1. Using date facets with Solr 3.1
What is the expected output? What do you see instead?
- Expected: Date facets functionality works.
- Actual: It falls over due to the presence of the additional date element with
the 'start' attribute.
<lst name="facet_dates">
<lst name="date_dt">
<str name="gap">+1DAY</str>
<date name="start">2011-02-26T00:00:00Z</date> *** new element ***
<date name="end">2011-03-04T00:00:00Z</date>
<int name="before">436</int>
<int name="after">0</int>
<int name="between">0</int>
</lst>
</lst>
Please use labels and text to provide additional information.
File: FacetsResponseParser.cs needs to be updated in order for solrnet to work
with Solr 3.1.
From:
public DateFacetingResult ParseDateFacetingNode(XElement node) {
var r = new DateFacetingResult();
var dateParser = new DateTimeFieldParser();
var intParser = new IntFieldParser();
foreach (var dateFacetingNode in node.Elements()) {
var name = dateFacetingNode.Attribute("name").Value;
switch (name) {
case "gap":
r.Gap = dateFacetingNode.Value;
break;
case "end":
r.End = (DateTime) dateParser.Parse(dateFacetingNode, typeof (DateTime));
break;
default:
var count = (int) intParser.Parse(dateFacetingNode, typeof (int));
if (name == FacetDateOther.After.ToString())
r.OtherResults[FacetDateOther.After] = count;
else if (name == FacetDateOther.Before.ToString())
r.OtherResults[FacetDateOther.Before] = count;
else if (name == FacetDateOther.Between.ToString())
r.OtherResults[FacetDateOther.Between] = count;
else {
var d = dateParser.ParseDate(name);
r.DateResults.Add(KV(d, count));
}
break;
}
}
return r;
}
To:
public DateFacetingResult ParseDateFacetingNode(XElement node) {
var r = new DateFacetingResult();
var dateParser = new DateTimeFieldParser();
var intParser = new IntFieldParser();
foreach (var dateFacetingNode in node.Elements()) {
var name = dateFacetingNode.Attribute("name").Value;
switch (name) {
case "gap":
r.Gap = dateFacetingNode.Value;
break;
case "end":
r.End = (DateTime) dateParser.Parse(dateFacetingNode, typeof (DateTime));
break;
case "start":
// Temp fix to support Solr 3.1, which has added a new element <date name="start">...</date>
// not seen in Solr 1.4 to the facet date response – just ignore this element.
// A more future-proofed fix may be to add a check within the default: block to only process
// if (dateFacetingNode.Name == "int").
// But best to extend DateFacetingResult to have a DateTime Start property, and set it here.
break;
default:
var count = (int) intParser.Parse(dateFacetingNode, typeof (int));
if (name == FacetDateOther.After.ToString())
r.OtherResults[FacetDateOther.After] = count;
else if (name == FacetDateOther.Before.ToString())
r.OtherResults[FacetDateOther.Before] = count;
else if (name == FacetDateOther.Between.ToString())
r.OtherResults[FacetDateOther.Between] = count;
else {
var d = dateParser.ParseDate(name);
r.DateResults.Add(KV(d, count));
}
break;
}
}
return r;
}
Cheers,
Scot
Original issue reported on code.google.com by moir.s...@gmail.com on 3 Mar 2011 at 9:50
Original issue reported on code.google.com by
moir.s...@gmail.com
on 3 Mar 2011 at 9:50