def search(self, x, quota=10, limit=None, with_dists=False):
        # Retrieve results with multi-index
        retrieved, visited = self.get_result_quota(x, quota)

        # Compute distance for results
        results = self.compute_distances(x, retrieved)

        # Sort by distance
        results = sorted(results, key=lambda d: d[0])

        # Limit number returned
        if limit is None:
            limit = quota
        results = results[:limit]

        if with_dists:
            Result = namedtuple('Result', ['id', 'code', 'dist'])
            results = map(lambda d: Result(d[1][0], d[1][1], d[0]), results)
        else:
            Result = namedtuple('Result', ['id', 'code'])
            results = map(lambda d: Result(d[1][0], d[1]), results)

        return results, visited
Helper to run the onvalidation routine for a record
dataset/ETHPy150Open yahoo/lopq/python/lopq/search.py/LOPQSearcherBase.search--crossover with--dataset/ETHPy150Open sahana/eden/modules/s3/s3model.py/S3Model.onaccept