1

I am converting a SOLR 4.10 db to SOLR 7.1

In 4.10, I have a field that is an expiration date, that I limit the scope of SOLR queries with, so I created an index field of type date, with a copy field, into a field in the output.

<field name="IDX_ExpirationDate" type="date" indexed="true" stored="false" multiValued="true" />
<field name="ExpirationDate" type = "date" indexed = "true" stored = "true" />
<copyField source="ExpirationDate" dest="IDX_ExpirationDate"/>

Using the schema above in 4.10, when I run a query, I get ExpirationDate in the results as expected.

 {
    ...
            "ExpirationDate":"2015-09-29T00:00:00Z",
    ...
    }

SOLR 7.1 got rid of the type "date" and replaced it with a type called "pdate", so I made the change in the 7.1 schema (only changed date to pdate)

<field name="IDX_ExpirationDate" type="pdate" indexed="true" stored="false" multiValued="true" />
<field name="ExpirationDate" type = "pdate" indexed = "true" stored = "true" />   
<copyField source="ExpirationDate" dest="IDX_ExpirationDate"/>

Now when I run SOLR 7.1 queries, i see both ExpirationDate and IDX_ExpirationDate in the results, and what's worse, its adding square braces around the date. (I'm viewing the results in json). So basically there are 2 problems. First IDX_ExpirationDate shouldnt be in the results because the "stored" attribute in the schema is false. Second, the square brackets treats the date like an array instead of a date, and fails JSON deserialization.

{
...
        "ExpirationDate":"2015-09-29T00:00:00Z",
        "IDX_ExpirationDate":["2015-09-29T00:00:00Z"],
...
}

Is there a setting that has changed since 4.10 that would cause this to appear? Or is there an extra attribute I need to set?

I have other IDX_ items but they are all type="text_general" instead of pdate - and they dont appear in the query results.

Rick Hodder
  • 2,189
  • 3
  • 26
  • 54
  • The simplest way is to determine the fields you want to get from the document. https://stackoverflow.com/questions/264907/retrieving-specific-fields-in-a-solr-query – SaidbakR Jan 18 '18 at 21:58
  • 1
    Thanks for the suggestion, but I am trying to figure out why it is appearing in the results - it shouldnt because its an index, maybe I missed a setting or attribute? or pdates may be a special case?- edited question above. – Rick Hodder Jan 18 '18 at 22:08

1 Answers1

1

If the field type has docValues enabled, and the Schema version is set to at least 1.6, DocValues will be used as the stored value if the stored value is not available.

For schema versions >= 1.6, the implicit default is useDocValuesAsStored="true".

And since docValues are required to make Point Dates sortable, I think they're currently enabled by default:

For single valued fields, docValues="true" must be used to enable sorting.

So to "fix" this, clear the index, set useDocValuesAsStored="false" for the field type and reindex. But you're getting this more or less for free, so it really shouldn't be a problem.

The [ and ] around your value is because the value is returned as a list, since the field is multi valued.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84