我正在开发一个项目,我们在MongoDB数据库中存储了数百万个条目,我想使用SOLR索引所有这些数据.
经过广泛的搜索后,我才知道mongoDB数据库没有合适的"数据导入处理程序".
谁能告诉我使用SOLR在MongoDB中索引数据的正确方法是什么?
我想使用SOLR的所有功能,并希望它可以实时扩展.我从不同的帖子中看到了一两种方法,但不确定它们将如何实时工作..
非常感谢
我一直在使用BeautifulSoup来解析html文件,而我编写的所有脚本都运行良好但速度很慢.所以我正在尝试使用多处理工作池和BeautifulSoup,这样我的程序可以更快地运行(我有100,000 - 1,000,000个html文件要打开).我写的脚本比较复杂,但我在这里写下了一个小例子.我试图做这样的事情,我一直在收到错误
'runtimeError:蚀刻对象时超出了最大递归深度'
编辑代码
from bs4 import BeautifulSoup
from multiprocessing import Pool
def extraction(path):
soup=BeautifulSoup(open(path),"lxml")
return soup.title
pool=Pool(processes=4)
path=['/Volume3/2316/http/www.metro.co.uk/news/852300-haiti-quake-victim-footballers-stage-special-tournament/crawlerdefault.html','/Volume3/2316/http/presszoom.com/story_164020.html']
print pool.map(extraction,path)
pool.close()
pool.join()
Run Code Online (Sandbox Code Playgroud)
在做了一些搜索和挖掘一些帖子之后,我知道错误正在发生,因为BeautifulSoup超出了python解释器堆栈的深度.我试图提高限制并运行相同的程序(我上升到3000)但错误仍然相同.我停止提高限制因为打开html文件时问题出在BeautifulSoup上.
使用BeautifulSoup进行多处理将加快我的执行时间,但我无法弄清楚如何应用它来打开文件.
有没有人有任何其他方法如何使用BeautifulSoup与多处理或如何克服这些错误?
任何形式的帮助将不胜感激,我坐了几个小时试图解决它并理解为什么我得到错误.
编辑
我用路径中给出的文件测试了上面的代码,我得到了与上面相同的RuntimeError
这些文件可以在这里访问(http://ec2-23-20-166-224.compute-1.amazonaws.com/sites/html_files/)
我正在编写一个示例程序来测试python 2.7.2+中多工作池的使用情况
这是我在python ubuntu解释器中编写的代码
>>> from multiprocessing import Pool
>>> def name_append(first_name,last_name):
... return first_name+" "+last_name
...
>>> from functools import partial
>>> partial_name_append=partial(name_append,'kiran')
>>> partial_name_append('acb')
'kiran acb'
>>> abc='kiran'
>>> pool=Pool(processes=4)
>>> pool.map(partial_name_append,abc)
['kiran k', 'kiran i', 'kiran r', 'kiran a', 'kiran n']
>>> pool.close()
>>> pool.join()
>>> pool.map(partial_name_append,abc)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/multiprocessing/pool.py", line 226, in map
assert self._state == RUN
AssertionError
Run Code Online (Sandbox Code Playgroud)
在我得到pickle错误之后,在我的工作池中为大数据集编写代码,我试图做一些小例子并试图找出错误是什么.
我不明白为什么同样的语句'pool.map'不起作用,当它在上面工作时.我想我已正确执行了"池地图",但我不明白原因.
此错误与"PicklingError:无法pickle:属性查找内置 .function失败"有关
有人可以帮我吗 ?
谢谢
我试图在URL字符串上使用python正则表达式.
id= 'edu.vt.lib.scholar:http/ejournals/VALib/v48_n4/newsome.html'
>>> re.search('news|ejournals|theses',id).group()
'ejournals'
>>> re.findall('news|ejournals|theses',id)
['ejournals', 'news']
Run Code Online (Sandbox Code Playgroud)
根据http://docs.python.org/2/library/re.html#finding-all-adverbs上的文档,它说search()匹配第一个,并查找字符串中所有可能的匹配.
我想知道为什么'新闻'没有被搜索捕获,即使它在模式中被宣布为第一.
我使用了错误的模式吗?我想搜索字符串中是否出现任何关键字.
我正在尝试使用urllib3连接到网页.代码如下.
import urllib3
http=urllib3.PoolManager()
fields={'username':'abc','password':'xyz'}
r=http.request('GET',url,fields)
Run Code Online (Sandbox Code Playgroud)
如果我们假设url是某个需要使用用户名和密码进行身份验证的网页,我是否使用正确的代码进行身份验证?
我使用urllib2非常舒服地做了这个,但是我无法使用urllib3做同样的事情.
非常感谢
我正在使用带有cherrypy框架的Jinja2.我写了下面的模板代码.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CTRnet Search</title>
</head>
<body>
<form action="search" method="post">
<p> Please enter your query to search in the collection</p>
<input type="text" name="query" value={{ parameters.query }} size="35" maxlength="60" />
<p><input type="submit" value="Search"/> <input type="reset" value="Clear"/></p>
</form>
<h2>The query is {{ parameters.query }}</h2>
<h2>About {{ parameters.numFound }} results</h2>
</body></html>
Run Code Online (Sandbox Code Playgroud)
我希望表单打印之前生成的查询的值.我从parameters.query字段获取上一个查询.如果我的查询是"弗吉尼亚",则表单会在文本框中正确显示.
如果我的查询是'弗吉尼亚地震',表格只显示'弗吉尼亚'.它不会在空格字符后打印任何内容.
它是否与表单不相符或与我的模板系统'Jinja2'有关.正确传递变量,我可以在表单后打印该变量.
在下面的屏幕截图中,我的查询是'弗吉尼亚地震',但表格框只打印'弗吉尼亚'.我正在学习如何设计网页,但我不确定这里要调试的是什么.

请让我知道你的建议!