Python search 模块,search() 实例源码

我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用search.search()

项目:social-vuln-scanner    作者:Betawolf    | 项目源码 | 文件源码
def extend(self):
    profile = self.profile
    res = search.search(profile.bestname(),['twitter.com','facebook.com','plus.google.com','linkedin.com'],True)
    for r in res:
      wp = WebProfiler.fromURL(r)
      if wp:
        resultprofile =  wp.getProfile()
        if resolver.areEquivalent(resultprofile,profile):
            #merge the mined fields.
            profile.names = list(set(profile.names+resultprofile.names))
            profile.education = list(set(profile.education+resultprofile.education))
            profile.location_set = list(set(profile.location_set+resultprofile.location_set))
            profile.email_addresses = list(set(profile.email_addresses+resultprofile.email_addresses))
            profile.phone_numbers = list(set(profile.phone_numbers+resultprofile.phone_numbers))
            profile.grouped = list(set(profile.grouped+resultprofile.grouped))
            profile.web_links = list(set(profile.web_links+resultprofile.web_links+[r]))
            profile.profile_links = list(set(profile.profile_links+resultprofile.profile_links))
        self.profile = profile
    return self.profile
项目:ecommerce_api    作者:nbschool    | 项目源码 | 文件源码
def search(self, query, attributes=['name', 'description'], limit=10):
        return search.search(query, attributes, Item.select(), limit)
项目:ecommerce_api    作者:nbschool    | 项目源码 | 文件源码
def test_search_tavolo_sedie(self):
        result = self.search('tavolo sedie')

        res = ['tavolo con sedie', 'tavolo con set di sedie', 'tavolo da cucina',
               'tavolino', 'tavola di legno', 'sedie', 'set di sedie', 'tavolo', 'tavola']
        assert res == get_names(result)
项目:ecommerce_api    作者:nbschool    | 项目源码 | 文件源码
def test_search_tavolo(self):
        result = self.search('tavolo')
        res = ['tavolo', 'tavolino', 'tavola', 'tavola di legno', 'legno di tavola',
               'tavolo con sedie', 'tavolo con set di sedie', 'tavolo da cucina', 'poltrona',
               'letto singolo']
        assert res == get_names(result)
项目:ecommerce_api    作者:nbschool    | 项目源码 | 文件源码
def test_search_sedia(self):
        result = self.search('sedia')

        res = ['sedie', 'set di sedie', 'sedie da cucina', 'sedie deco',
               'divano', 'tavolo con sedie', 'tavolo con set di sedie', 'divano letto']
        assert res == get_names(result)
项目:ecommerce_api    作者:nbschool    | 项目源码 | 文件源码
def test_search_sedie(self):
        result = self.search('sedie')

        res = ['sedie', 'set di sedie', 'sedie deco', 'sedie da cucina',
               'tavolo con sedie', 'tavolo con set di sedie', 'scarpine']
        assert res == get_names(result)
项目:ecommerce_api    作者:nbschool    | 项目源码 | 文件源码
def test_search_letto(self):
        result = self.search('letto')

        res = ['letto', 'letto matrimoniale', 'divano letto', 'letto singolo', 'letto francese',
               'tavola di legno', 'legno di tavola', 'poltrona elettrica', 'sedie deco', 'tavolo']
        assert res == get_names(result)
项目:ecommerce_api    作者:nbschool    | 项目源码 | 文件源码
def test_search_scarpette(self):
        result = self.search('scarpette')

        res = ['scarpette', 'scarpe', 'scarpine', 'scarpacce', 'scarponi',
               'scarpe da ginnastica', 'scarpe da ballo', 'maglietta', 'canottiera',
               'letto francese']
        assert res == get_names(result)
项目:ecommerce_api    作者:nbschool    | 项目源码 | 文件源码
def test_search_scarponi(self):
        result = self.search('scarponi')

        res = ['scarponi', 'scarpine', 'scarpe', 'scarpette',
               'scarpacce', 'scarpe da ballo', 'scarpe da ginnastica']
        assert res == get_names(result)
项目:ecommerce_api    作者:nbschool    | 项目源码 | 文件源码
def test_search_divano(self):
        result = self.search('divano')

        res = ['divano', 'divano letto']
        assert res == get_names(result)
项目:esper    作者:scanner-research    | 项目源码 | 文件源码
def search2(request):
    params = json.loads(request.body)
    return search.search(params)


# Get distinct values in schema
项目:social-vuln-scanner    作者:Betawolf    | 项目源码 | 文件源码
def fromPerson(person):
    approved = None
    for profile in person.profiles:
      res = search.search(profile.bestname(),['twitter.com','facebook.com','plus.google.com','linkedin.com'],True)
      for r in res:
        wp = WebProfiler.fromURL(r)
        if wp:
            resultprofile = wp.getProfile()
            if resultprofile and resolver.areEquivalent(resultprofile,profile):
              approved = resultprofile
              break
    return approved
项目:SinaWeibo    作者:chengshuyi    | 项目源码 | 文件源码
def main(c,t='????',p=2):
    sh  =search(c)
    lt  =sh.search(t,p)
    setWeiboMongo(lt)
    rst=getOneWeibo()
    if rst is False:
        print('No more weibo to retweet!')
        return False
    rt=retweet(c)
    state=rt.retweet(rst['mid'],rst['reason'])
    if state:
        return rst
    return False
项目:ecommerce_api    作者:nbschool    | 项目源码 | 文件源码
def search(cls, query, dataset, limit=-1,
               attributes=None, weights=None,
               threshold=search.config.THRESHOLD):
        """
        Search a list of resources with the callee class.

        Arguments:
            query (str): Query to lookup for
            dataset (iterable): sequence of resource objects to lookup into
            limit (int): maximum number of resources to return (default -1, all)
            attributes (list): model attribute names. Can be set as default
                inside the model definition or specified on the fly while
                searching.
            weights (list): attributes weights values,indexes should
                match the attribute position in the `attributes` argument.
                if length does not match it will be ignored.
            threshold (float): value between 0 and 1, identify the matching
                threshold for a result to be included.

        Returns:
            list: list of resources that may match the query.

        Raises:
            SearchAttributeMismatch:
                if ``attributes`` are missing, either as model
                default in ``<Model>._search_attributes`` or as param
                one of the object does not have one of the given attribute(s).

        Examples:

            .. code-block:: python

                results = Item.search('shoes', Item.select(), limit=20)
        """

        attributes = attributes or cls._search_attributes
        weights = weights or cls._search_weights

        if not attributes:
            raise SearchAttributeMismatch(
                'Attributes to look for not defined for {}. \
                Please update the Model or specify during search call.\
                '.format(cls.__name__))

        return search.search(query, attributes, dataset, limit, threshold, weights)