MCPcopy Create free account
hub / github.com/django-haystack/django-haystack / full_prepare

Method full_prepare

haystack/indexes.py:234–263  ·  view source on GitHub ↗
(self, obj, with_string_facet=True)

Source from the content-addressed store, hash-verified

232 return self.prepared_data
233
234 def full_prepare(self, obj, with_string_facet=True):
235 self.prepared_data = self.prepare(obj)
236
237 for field_name, field in self.fields.items():
238 # Duplicate data for faceted fields.
239 if (
240 not with_string_facet
241 and field.field_type == "string"
242 and getattr(field, "facet_for", None) in self.fields
243 ):
244 continue
245 if getattr(field, "facet_for", None):
246 source_field_name = self.fields[field.facet_for].index_fieldname
247
248 # If there's data there, leave it alone. Otherwise, populate it
249 # with whatever the related field has.
250 if (
251 self.prepared_data[field_name] is None
252 and source_field_name in self.prepared_data
253 ):
254 self.prepared_data[field.index_fieldname] = self.prepared_data[
255 source_field_name
256 ]
257
258 # Remove any fields that lack a value and are ``null=True``.
259 if field.null is True:
260 if self.prepared_data[field.index_fieldname] is None:
261 del self.prepared_data[field.index_fieldname]
262
263 return self.prepared_data
264
265 def get_content_field(self):
266 """Returns the field that supplies the primary document to be indexed."""

Callers 10

updateMethod · 0.80
_prepare_objectMethod · 0.80
updateMethod · 0.80
test_custom_prepareMethod · 0.80
test_nullableMethod · 0.80
test_full_prepareMethod · 0.80
updateMethod · 0.80

Calls 1

prepareMethod · 0.95

Tested by 6

test_custom_prepareMethod · 0.64
test_nullableMethod · 0.64
test_full_prepareMethod · 0.64