MCPcopy Index your code
hub / github.com/django-haystack/django-haystack / add

Method add

haystack/backends/__init__.py:319–340  ·  view source on GitHub ↗

Adds a new node to the tree. If the conn_type is the same as the root's current connector type, the node is added to the first level. Otherwise, the whole tree is pushed down one level and a new root connector is created, connecting the existing tree and the new node

(self, node, conn_type)

Source from the content-addressed store, hash-verified

317 return other in self.children
318
319 def add(self, node, conn_type):
320 """
321 Adds a new node to the tree. If the conn_type is the same as the root's
322 current connector type, the node is added to the first level.
323 Otherwise, the whole tree is pushed down one level and a new root
324 connector is created, connecting the existing tree and the new node.
325 """
326 if node in self.children and conn_type == self.connector:
327 return
328 if len(self.children) < 2:
329 self.connector = conn_type
330 if self.connector == conn_type:
331 if isinstance(node, SearchNode) and (
332 node.connector == conn_type or len(node) == 1
333 ):
334 self.children.extend(node.children)
335 else:
336 self.children.append(node)
337 else:
338 obj = self._new_instance(self.children, self.connector, self.negated)
339 self.connector = conn_type
340 self.children = [obj, node]
341
342 def negate(self):
343 """

Callers 12

updateMethod · 0.80
build_search_kwargsMethod · 0.80
more_like_thisMethod · 0.80
searchMethod · 0.80
searchMethod · 0.80
more_like_thisMethod · 0.80
add_filterMethod · 0.80
add_modelMethod · 0.80
add_narrow_queryMethod · 0.80
update_backendMethod · 0.80
test_full_prepareMethod · 0.80

Calls 1

_new_instanceMethod · 0.95