Note that there are some explanatory texts on larger screens.

plurals
  1. POSolrnet date conversion issue
    text
    copied!<p>We are using SolrNet API to Index and Search a set of documents which contains three date fields: Date1, Date2, Date3. The C# class has the following definitions for the three fields</p> <pre><code>public DateTime? Date1{ get; set; } public DateTime? Date2{ get; set; } public DateTime? Date3{ get; set; } </code></pre> <p>The Solr schema definition is as follows:</p> <pre><code>&lt;field name="Date1" type="date" indexed="false" stored="true" required="false"/&gt; &lt;field name="Date2" type="date" indexed="false" stored="true" required="false"/&gt; &lt;field name="Date3" type="date" indexed="false" stored="true" required="false"/&gt; </code></pre> <p>When we execute a query with a document which has already been indexed, we get the following values returned in the SolrAdmin interface:</p> <pre><code>&lt;date name="Date1"&gt;0001-01-01T00:00:00Z&lt;/date&gt; &lt;date name="Date2"&gt;2010-04-10T08:21:18.281Z&lt;/date&gt; &lt;date name="Date3"&gt;2007-12-01T03:09:41.093Z&lt;/date&gt; </code></pre> <p>But when we inspect the C# object which gets returned with the SolrQueryResults, it shows the following:</p> <pre><code>Date1 : {01-01-0001 12:00:00 AM} Date2 : null Date3 : null </code></pre> <p>The first date is being represented as the datetime min value which is expected. But why are the other dates getting null values when these are valid dates in the UTC format?</p> <p>Is it better to store the date fields as strings in Solr and use a copy field to store it in the solr date format and use this field for date range queries?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload