I have an MVC application which is querying a Lucene/Solr index. In a partial view, I am displaying metadata on a series of XML documents returned from the query. The metadata is extracted from the XML documents using XPath queries and is paged, listing 10 documents at a time. The view cshtml is as follows...
@model SolrMVCTest2.Models.Facet
<section>
@foreach (System.Xml.XmlNode doc in Model.SearchResult.SelectNodes("/response/result/doc"))
{
<article>
<b>Document type: @doc.SelectSingleNode("//str[@name='docType']").InnerText </b> <br />
<b>NHS Number: @doc.SelectSingleNode("//str[@name='crn']").InnerText </b> <br />
@doc.OuterXml.ToString()
</article>
<p></p>
}
</section>
I have included a display of the OuterXML for debugging purposes and a partial listing of the results highlights a serious issue. FOr each group of 10 documents, the innertext of the selected nodes is not updated for each successive document, but always displays the values from the first document of the set of 10 as shown in this partial result....
Document type: MedicalHistory
Patient Number: 7024326654
<doc><str name="id">mh00k2jr001002</str><str name="crn">7024326654</str><str name="docType">MedicalHistory</str></doc>
Document type: MedicalHistory
Patient Number: 7024326654
<doc><str name="id">mh00k2ju001002</str><str name="crn">0437861414</str><str name="docType">MedicalHistory</str></doc>
Document type: MedicalHistory
Patient Number: 7024326654
<doc><str name="id">mh00k2k1001002</str><str name="crn">7626346416</str><str name="docType">MedicalHistory</str></doc>
Document type: MedicalHistory
Patient Number: 7024326654
<doc><str name="id">mh00k2mp001002</str><str name="crn">2637403616</str><str name="docType">MedicalHistory</str></doc>
Document type: MedicalHistory
Patient Number: 7024326654
<doc><str name="id">mh00k2nm001001</str><str name="crn">0874706416</str><str name="docType">MedicalHistory</str></doc>
Document type: MedicalHistory
Patient Number: 7024326654
<doc><str name="id">mh00k2qq001002</str><str name="crn">1867082616</str><str name="docType">MedicalHistory</str></doc>
Document type: MedicalHistory
Patient Number: 7024326654
<doc><str name="id">mh00k2ss001001</str><str name="crn">5436985416</str><str name="docType">MedicalHistory</str></doc>
Document type: MedicalHistory
Patient Number: 7024326654
<doc><str name="id">mh00k2yi002003</str><str name="crn">8731654606</str><str name="docType">MedicalHistory</str></doc>
Document type: MedicalHistory
Patient Number: 7024326654
<doc><str name="id">mh00k2yr001001</str><str name="crn">0906133416</str><str name="docType">MedicalHistory</str></doc>
Document type: MedicalHistory
Patient Number: 7024326654
<doc><str name="id">op00k23e001001</str><str name="crn">6335192616</str><str name="docType">OutpatientAnnotation</str></doc>
The Patient Number display (extracted from the str element named "crn" is not updated obn the second and successive documents, and the Document Type (fromt he docType element) is not updated on the 10th.
Does anyone have any ideas which may explain this behaviour?