Example #1
0
    def get_all_text(self):
        """
        Returns the content that is stored in the combined_index_data.all_text
        field, and raise a `FieldNotAvailable` exception when it is not
        available.

        :rtype: unicode
        """
        combined_index_data = json.loads(self.original_item['_source'].get(
            'combined_index_data', {}))
        all_text = combined_index_data.get('all_text')
        if not all_text:
            raise FieldNotAvailable('combined_index_data.all_text')
        return all_text
Example #2
0
    def get_combined_index_data(self):
        combined_index_data = self.original_item['_source']\
            .get('combined_index_data')
        if not combined_index_data:
            raise FieldNotAvailable('combined_index_data')

        data = json.loads(combined_index_data)
        data.pop('meta')
        # Cast datetimes
        for key, value in data.iteritems():
            if self.combined_index_fields.get(key) == datetime:
                data[key] = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S')

        return data
Example #3
0
 def get_rights(self):
     rights = self.original_item['_source'].get('meta', {}).get('rights')
     if not rights:
         raise FieldNotAvailable('rights')
     return rights
Example #4
0
 def get_original_object_urls(self):
     original_object_urls = self.original_item['_source'].get('meta', {})\
         .get('original_object_urls')
     if not original_object_urls:
         raise FieldNotAvailable('original_object_urls')
     return original_object_urls
Example #5
0
 def get_collection(self):
     collection = self.original_item['_source'].get('meta', {})\
         .get('collection')
     if not collection:
         raise FieldNotAvailable('collection')
     return collection