当前位置: 首页>>代码示例>>Python>>正文


Python pysolr.Solr方法代码示例

本文整理汇总了Python中pysolr.Solr方法的典型用法代码示例。如果您正苦于以下问题:Python pysolr.Solr方法的具体用法?Python pysolr.Solr怎么用?Python pysolr.Solr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pysolr的用法示例。


在下文中一共展示了pysolr.Solr方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def __init__(self, params):
        self.collection_name = params["collection_name"]
        self.solr_address = params["solr_address"]
        self.solr = pysolr.Solr(
            "{}/solr/{}".format(self.solr_address, self.collection_name),
            always_commit=True,
            timeout=100,
        )
        self.rows = params["rows"]
        self.query_data = params["query_data"]
        self.c = 0
        self.query_arguments = {
            "fl": "* score",
            "rows": self.rows,
            "defType": "edismax",
        }

        if params["boosting"] is not None:
            self.query_arguments["bf"] = params["boosting"] 
开发者ID:facebookresearch,项目名称:BLINK,代码行数:21,代码来源:candidate_generators.py

示例2: __init__

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def __init__(self, params):
        self.solr_address = params["solr_address"]
        self.raw_solr_fields = params["raw_solr_fields"]
        self.solr = pysolr.Solr(self.solr_address, always_commit=True, timeout=100)
        self.rows = params["rows"]
        self.query = params["query"]
        self.keys = [k.strip() for k in params["keys"].split(",")]
        self.c = 0
        self.query_arguments = {
            "fl": "* score",
            "rows": self.rows,
            "defType": "edismax",
        }

        if params["boosting"] is not None:
            self.query_arguments["bf"] = params["boosting"] 
开发者ID:facebookresearch,项目名称:BLINK,代码行数:18,代码来源:candidate_generation.py

示例3: search_associations_go

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def search_associations_go(
        subject_category=None,
        object_category=None,
        relation=None,
        subject=None,
        **kwargs):
    """
    Perform association search using Monarch golr
    """
    go_golr_url = "http://golr.geneontology.org/solr/"
    go_solr = pysolr.Solr(go_golr_url, timeout=5)
    go_solr.get_session().headers['User-Agent'] = get_user_agent(caller_name=__name__)
    return search_associations(subject_category,
                               object_category,
                               relation,
                               subject,
                               solr=go_solr,
                               field_mapping=goassoc_fieldmap(),
                               **kwargs) 
开发者ID:biolink,项目名称:ontobio,代码行数:21,代码来源:golr_associations.py

示例4: map_id

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def map_id(self,id, prefix, closure_list):
        """
        Map identifiers based on an equivalence closure list.
        """
        prefixc = prefix + ':'
        ids = [eid for eid in closure_list if eid.startswith(prefixc)]
        # TODO: add option to fail if no mapping, or if >1 mapping
        if len(ids) == 0:
            # default to input
            return id
        return ids[0]





### This may quite possibly be a temporary code, but it looks a lot simpler than the above for more customizable Solr queries 
开发者ID:biolink,项目名称:ontobio,代码行数:19,代码来源:golr_query.py

示例5: test_clinical_modifiers

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def test_clinical_modifiers():
    """
    Test that clinical modifiers show up in the GolrAssociationQuery.exec() object
    when present in the input solr document
    """
    manager = GolrAssociationQuery()
    manager.solr = pysolr.Solr(url="mock_solr", timeout=10)
    input_fh = os.path.join(os.path.dirname(__file__),
                            'resources/solr/input/clinical-mod-doc.json')
    input_docs = json.load(open(input_fh))
    expected_fh = os.path.join(os.path.dirname(__file__),
                               'resources/solr/expected/clinical-mod.json')
    expected_obj = json.load(open(expected_fh))

    manager.solr.search = MagicMock(return_value=pysolr.Results(input_docs))
    results = manager.exec()
    assert json.dumps(expected_obj, sort_keys=True) == \
           json.dumps(results,
                      default=lambda obj: getattr(obj, '__dict__', str(obj)),
                      sort_keys=True) 
开发者ID:biolink,项目名称:ontobio,代码行数:22,代码来源:test_clinical_mod.py

示例6: download_and_extract

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def download_and_extract(resource_url):
    """
    Download resource and extract metadata using Solr.

    The extracted metadata is cleaned and returned.
    """
    session = Session()
    request = Request('GET', resource_url).prepare()
    for plugin in PluginImplementations(IExtractorRequest):
        request = plugin.extractor_before_request(request)
    with tempfile.NamedTemporaryFile() as f:
        r = session.send(request, stream=True)
        r.raise_for_status()
        for chunk in r.iter_content(chunk_size=1024):
            f.write(chunk)
        f.flush()
        f.seek(0)
        data = pysolr.Solr(config['solr_url']).extract(f, extractFormat='text')
    data['metadata']['fulltext'] = data['contents']
    return dict(clean_metadatum(*x) for x in data['metadata'].iteritems()) 
开发者ID:stadt-karlsruhe,项目名称:ckanext-extractor,代码行数:22,代码来源:lib.py

示例7: is_available

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def is_available():
    """
    Return true if we can successfully connect to Solr.
    """
    try:
        conn = make_connection()
        conn.search(q="*:*", rows=1)
    except Exception, e:
        log.exception(e)
        return False 
开发者ID:italia,项目名称:daf-recipes,代码行数:12,代码来源:common.py

示例8: make_connection

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def make_connection(decode_dates=True):
    solr_url, solr_user, solr_password = SolrSettings.get()
    if decode_dates:
        decoder = simplejson.JSONDecoder(object_hook=solr_datetime_decoder)
        return pysolr.Solr(solr_url, decoder=decoder)
    else:
        return pysolr.Solr(solr_url) 
开发者ID:italia,项目名称:daf-recipes,代码行数:9,代码来源:common.py

示例9: _set_solr

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def _set_solr(self, url, timeout=2):
        self.solr = pysolr.Solr(url=url, timeout=timeout)
        return self.solr 
开发者ID:biolink,项目名称:ontobio,代码行数:5,代码来源:golr_query.py

示例10: __init__

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def __init__(self, config):
        self.solrUrl = config.get("solr", "host")
        self.solrCore = config.get("solr", "core")
        self.logger = logging.getLogger('nexus')

        with SOLR_CON_LOCK:
            solrcon = getattr(thread_local, 'solrcon', None)
            if solrcon is None:
                solrcon = pysolr.Solr('http://%s/solr/%s' % (self.solrUrl, self.solrCore))
                thread_local.solrcon = solrcon

            self.solrcon = solrcon 
开发者ID:apache,项目名称:incubator-sdap-nexus,代码行数:14,代码来源:SolrProxy.py

示例11: make_solr_from_config

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def make_solr_from_config(push_servers, query_server=None, **kwargs):
    """
    Make a :class:`Solr <Solr>` instance from config defaults.  Use
    `**kwargs` to override any value
    """
    solr_kwargs = dict(
        commit=asbool(config.get('solr.commit', True)),
        commitWithin=config.get('solr.commitWithin'),
        timeout=int(config.get('solr.long_timeout', 60)),
    )
    solr_kwargs.update(kwargs)
    return Solr(push_servers, query_server, **solr_kwargs) 
开发者ID:apache,项目名称:allura,代码行数:14,代码来源:solr.py

示例12: __init__

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def __init__(self, push_servers, query_server=None,
                 commit=True, commitWithin=None, **kw):
        self.push_pool = [pysolr.Solr(s, **kw) for s in push_servers]
        if query_server:
            self.query_server = pysolr.Solr(query_server, **kw)
        else:
            self.query_server = self.push_pool[0]
        self._commit = commit
        self.commitWithin = commitWithin 
开发者ID:apache,项目名称:allura,代码行数:11,代码来源:solr.py

示例13: index

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def index(self):
        """send csv to Solr index"""
        self.logger.info('Setting up Solr index...')
        solr = Solr("http://{0}:{1}/solr/travel/".format(self.host, self.port), timeout=10000)
        
        self.logger.info('Indexing %s...' % self.file)
        act = [self.format(passage, cid=cid) for cid, passage in self.csv_generator()]
        solr.add(act)

        solr.optimize() 
开发者ID:koursaros-ai,项目名称:nboost,代码行数:12,代码来源:solr.py

示例14: _merge_kwargs

# 需要导入模块: import pysolr [as 别名]
# 或者: from pysolr import Solr [as 别名]
def _merge_kwargs(additionalparams, **kwargs):
        # Only Solr-specific kwargs are parsed
        # And the special 'limit'
        try:
            additionalparams['limit'] = kwargs['limit']
        except KeyError:
            pass

        try:
            additionalparams['_route_'] = kwargs['_route_']
        except KeyError:
            pass

        try:
            additionalparams['rows'] = kwargs['rows']
        except KeyError:
            pass

        try:
            additionalparams['start'] = kwargs['start']
        except KeyError:
            pass

        try:
            kwfq = kwargs['fq'] if isinstance(kwargs['fq'], list) else list(kwargs['fq'])
        except KeyError:
            kwfq = []

        try:
            additionalparams['fq'].extend(kwfq)
        except KeyError:
            additionalparams['fq'] = kwfq

        try:
            kwfl = kwargs['fl'] if isinstance(kwargs['fl'], list) else [kwargs['fl']]
        except KeyError:
            kwfl = []

        try:
            additionalparams['fl'].extend(kwfl)
        except KeyError:
            additionalparams['fl'] = kwfl

        try:
            s = kwargs['sort'] if isinstance(kwargs['sort'], list) else [kwargs['sort']]
        except KeyError:
            s = None

        try:
            additionalparams['sort'].extend(s)
        except KeyError:
            if s is not None:
                additionalparams['sort'] = s 
开发者ID:apache,项目名称:incubator-sdap-nexus,代码行数:55,代码来源:SolrProxy.py


注:本文中的pysolr.Solr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。