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


Python solr.SolrConnection类代码示例

本文整理汇总了Python中collective.solr.solr.SolrConnection的典型用法代码示例。如果您正苦于以下问题:Python SolrConnection类的具体用法?Python SolrConnection怎么用?Python SolrConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_commit_no_wait

 def test_commit_no_wait(self):
     commit_request = getData('commit_request_no_wait.txt')
     commit_response = getData('commit_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     output = fakehttp(c, commit_response)
     c.commit(waitFlush=False, waitSearcher=False)
     self.failUnlessEqual(str(output), commit_request)
开发者ID:andrgrau,项目名称:collective.solr,代码行数:7,代码来源:test_solr.py

示例2: test_optimize

 def test_optimize(self):
     commit_request = getData('optimize_request.txt')
     commit_response = getData('commit_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     output = fakehttp(c, commit_response)
     c.commit(optimize=True)
     self.failUnlessEqual(str(output), commit_request)
开发者ID:andrgrau,项目名称:collective.solr,代码行数:7,代码来源:test_solr.py

示例3: test_commit_no_wait_flush

 def test_commit_no_wait_flush(self):
     commit_request = getData('commit_request.txt').rstrip('\n')
     commit_response = getData('commit_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     output = fakehttp(c, commit_response)
     c.commit()
     self.failUnlessEqual(str(output), commit_request)
开发者ID:collective,项目名称:collective.solr,代码行数:7,代码来源:test_solr.py

示例4: test_search

 def test_search(self):
     search_request = getData('search_request.txt')
     search_response = getData('search_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     output = fakehttp(c, search_response)
     res = c.search(q='+id:[* TO *]', wt='xml', rows='10', indent='on')
     res = fromstring(res.read())
     self.failUnlessEqual(str(output), search_request)
     self.failUnless(res.find(('.//doc')))
开发者ID:Jarn,项目名称:collective.solr,代码行数:9,代码来源:test_solr.py

示例5: test_search

 def test_search(self):
     search_request = getData('search_request.txt')
     search_response = getData('search_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     output = fakehttp(c, search_response)
     res = c.search(q='+id:[* TO *]', fl='* score', wt='xml', rows='10', indent='on')
     res = fromstring(res.read())
     normalize = lambda x: sorted(x.split('&'))      # sort request params
     self.assertEqual(normalize(output.get()), normalize(search_request))
     self.failUnless(res.find(('.//doc')))
开发者ID:andrgrau,项目名称:collective.solr,代码行数:10,代码来源:test_solr.py

示例6: test_add_with_boost_values

 def test_add_with_boost_values(self):
     add_request = getData('add_request_with_boost_values.txt')
     add_response = getData('add_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     output = fakehttp(c, add_response)
     boost = {'': 2, 'id': 0.5, 'name': 5}
     c.add(boost_values=boost, id='500', name='python test doc')
     res = c.flush()
     self.assertEqual(len(res), 1)   # one request was sent
     res = res[0]
     self.failUnlessEqual(str(output), add_request)
开发者ID:andrgrau,项目名称:collective.solr,代码行数:11,代码来源:test_solr.py

示例7: test_commit

 def test_commit(self):
     commit_request = getData('commit_request.txt')
     commit_response = getData('commit_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     output = fakehttp(c, commit_response)
     res = c.commit()
     self.assertEqual(len(res), 1)   # one request was sent
     res = res[0]
     self.failUnlessEqual(str(output), commit_request)
     # Status
     node = res.findall(".//int")[0]
     self.failUnlessEqual(node.attrib['name'], 'status')
     self.failUnlessEqual(node.text, '0')
     # QTime
     node = res.findall(".//int")[1]
     self.failUnlessEqual(node.attrib['name'], 'QTime')
     self.failUnlessEqual(node.text, '55')
     res.find('QTime')
开发者ID:andrgrau,项目名称:collective.solr,代码行数:18,代码来源:test_solr.py

示例8: test_add

 def test_add(self):
     add_request = getData('add_request.txt')
     add_response = getData('add_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     output = fakehttp(c, add_response)
     c.add(id='500', name='python test doc')
     res = c.flush()
     self.assertEqual(len(res), 1)   # one request was sent
     res = res[0]
     self.failUnlessEqual(str(output), add_request)
     # Status
     node = res.findall(".//int")[0]
     self.failUnlessEqual(node.attrib['name'], 'status')
     self.failUnlessEqual(node.text, '0')
     # QTime
     node = res.findall(".//int")[1]
     self.failUnlessEqual(node.attrib['name'], 'QTime')
     self.failUnlessEqual(node.text, '4')
     res.find('QTime')
开发者ID:andrgrau,项目名称:collective.solr,代码行数:19,代码来源:test_solr.py

示例9: test_delete

 def test_delete(self):
     delete_request = getData('delete_request.txt').rstrip('\n')
     delete_response = getData('delete_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     output = fakehttp(c, delete_response)
     c.delete('500')
     res = c.flush()
     self.assertEqual(len(res), 1)   # one request was sent
     res = res[0]
     self.failUnlessEqual(str(output), delete_request)
     # Status
     node = res.findall(".//int")[0]
     self.failUnlessEqual(node.attrib['name'], 'status')
     self.failUnlessEqual(node.text, '0')
     # QTime
     node = res.findall(".//int")[1]
     self.failUnlessEqual(node.attrib['name'], 'QTime')
     self.failUnlessEqual(node.text, '0')
     res.find('QTime')
开发者ID:collective,项目名称:collective.solr,代码行数:19,代码来源:test_solr.py

示例10: test_add

    def test_add(self):
        config = getConfig()
        config.atomic_updates = True
        add_request = getData('add_request.txt').rstrip('\n')
        add_response = getData('add_response.txt')

        c = SolrConnection(host='localhost:8983', persistent=True)

        # fake schema response - caches the schema
        fakehttp(c, getData('schema.xml'))
        c.get_schema()

        output = fakehttp(c, add_response)
        c.add(id='500', name='python test doc')
        res = c.flush()
        self.assertEqual(len(res), 1)   # one request was sent
        res = res[0]
        self.failUnlessEqual(str(output), add_request)
        # Status
        node = res.findall(".//int")[0]
        self.failUnlessEqual(node.attrib['name'], 'status')
        self.failUnlessEqual(node.text, '0')
        # QTime
        node = res.findall(".//int")[1]
        self.failUnlessEqual(node.attrib['name'], 'QTime')
        self.failUnlessEqual(node.text, '4')
        res.find('QTime')
开发者ID:collective,项目名称:collective.solr,代码行数:27,代码来源:test_solr.py

示例11: test_search

    def test_search(self):
        # XXX: Solr 7 has a new query param 'q.op' which can not be passed to
        # the search method in Python.
        # This is why we have commented out code here.
        search_request = getData('search_request.txt').rstrip('\n')
        search_response = getData('search_response.txt')
        c = SolrConnection(host='localhost:8983', persistent=True)
        output = fakehttp(c, search_response)
        parameters = {'q': '+id:[* TO *]',
                      'fl': '* score',
                      'wt': 'xml',
                      'rows': '10',
                      'indent': 'on',
                      'q.op': 'AND',
                      'lowercaseOperators': 'true',
                      'sow': 'true'}

        res = c.search(**parameters)
        res = fromstring(res.read())
        normalize = lambda x: sorted(x.split('&'))      # sort request params
        self.assertEqual(normalize(output.get()), normalize(search_request))
        self.failUnless(res.find(('.//doc')))
开发者ID:collective,项目名称:collective.solr,代码行数:22,代码来源:test_solr.py

示例12: test_add_with_boost_values

    def test_add_with_boost_values(self):
        config = getConfig()
        config.atomic_updates = False
        add_request = getData('add_request_with_boost_values.txt')
        add_response = getData('add_response.txt')
        c = SolrConnection(host='localhost:8983', persistent=True)

        # fake schema response - caches the schema
        fakehttp(c, getData('schema.xml'))
        c.get_schema()

        output = fakehttp(c, add_response)
        boost = {'': 2, 'id': 0.5, 'name': 5}
        c.add(boost_values=boost,
              atomic_updates=False,  # Force disabling atomic updates
              id='500',
              name='python test doc')

        res = c.flush()
        self.assertEqual(len(res), 1)   # one request was sent
        self.failUnlessEqual(str(output), add_request)
开发者ID:FHNW,项目名称:collective.solr,代码行数:21,代码来源:test_solr.py

示例13: test_search_with_custom_request_handler

 def test_search_with_custom_request_handler(self):
     search_response = getData('search_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     fakehttp(c, search_response)
     c.search(request_handler='custom', q='+id:[* TO *]')
     self.assertEqual('/solr/custom', c.conn.url)
开发者ID:FHNW,项目名称:collective.solr,代码行数:6,代码来源:test_solr.py


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