lugensa / scorched

Sunburnt offspring solr client
MIT License
27 stars 19 forks source link

Include `pdate` as a date type? #58

Open ldaverio opened 3 years ago

ldaverio commented 3 years ago

Hello,

it seems that example files in recent Solr distributions define dates using a pdate, not date type in the schema.xml file:

    <fieldType name="pdate" class="solr.DatePointField" docValues="true"/>

This type is not recognised as a date type by Scorched, because date types are defined in method SolrInterface._extract_datefields in file connection.py:

    def _extract_datefields(self, schema):
        ret = [x['name'] for x in
               schema['fields'] if x['type'] == 'date']
        ret.extend([x['name'] for x in schema['dynamicFields']
                    if x['type'] == 'date'])
        return ret

Recognising pdateas a date could be achieved by replacing the two occurrences of the test:

if x['type'] == 'date'

by:

if x['type'] in ('date', 'pdate')

For now, the workaround is to rename pdate to date in the schema file.