def NearNode(self, node): """ near search isn't working yet """ word_nodes = [] word_nodes = flatten_NearNode(node.getValue(), word_nodes) sets = [self(n) for n in word_nodes] rs = intersectionResultSets(sets) raise NotImplementedError('Near search not implemented yet')
def PhraseNode(self, node): # Dealing with PhraseNodes is somewhat tricks # node.getValue() should return a sequence of WordNodes representing # the terms of the phrase # first tcreate he a copy of the ordered(!) terms words = [n.getValue() for n in node.getValue()] # So first perform a simple word search for all terms sets = [self(n) for n in node.getValue()] # Now intersect the results (AND). This descreases the number of documents # to be checked. rs = intersectionResultSets(sets) # Now check if the found documents really contain the words as phrase return lookup_by_phrase(self.searchrequest, rs.getDocids(), words, self._getField(node))
def AndNode(self, node): sets = [self(n) for n in node.getValue()] return intersectionResultSets(sets)