本文整理汇总了Python中collective.solr.solr.SolrConnection.add方法的典型用法代码示例。如果您正苦于以下问题:Python SolrConnection.add方法的具体用法?Python SolrConnection.add怎么用?Python SolrConnection.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collective.solr.solr.SolrConnection
的用法示例。
在下文中一共展示了SolrConnection.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add
# 需要导入模块: from collective.solr.solr import SolrConnection [as 别名]
# 或者: from collective.solr.solr.SolrConnection import add [as 别名]
def test_add(self):
config = getConfig()
config.atomic_updates = True
add_request = getData('add_request.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)
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')
示例2: test_add_with_boost_values
# 需要导入模块: from collective.solr.solr import SolrConnection [as 别名]
# 或者: from collective.solr.solr.SolrConnection import add [as 别名]
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)
示例3: test_add_with_boost_values
# 需要导入模块: from collective.solr.solr import SolrConnection [as 别名]
# 或者: from collective.solr.solr.SolrConnection import add [as 别名]
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)