我已经成功地用pysolr构建了一个python搜索应用程序。到目前为止,我已经使用了两个字段: id和title。现在,我想推动两个不同版本的标题:原始和标题后,删除停止词。有什么想法吗?以下代码起作用:
def BuildSolrIndex(solr, trandata):
tmp = []
for i, dat in enumerate(trandata):
if all(d is not None and len(d) > 0 for d in dat):
d = {}
d["id"] = dat[0]
d["title"] = dat[1]
tmp.append(d)
solr.add(tmp)
solr.optimize()
return solr但这一次却没有:
def BuildSolrIndex(solr, trandata):
tmp = []
for i, dat in enumerate(trandata):
if all(d is not None and len(d) > 0 for d in dat):
d = {}
d["id"] = dat[0]
d["title_org"] = dat[1]
d["title_new"] = CleanUpTitle(dat[1])
tmp.append(d)
solr.add(tmp)
solr.optimize()
return solr有什么想法吗?
编辑:
贝娄是例外:
Traceback (most recent call last):
...
solr = BuildSolrIndex(solr, trandata)
File "...", line 56, in BuildSolrIndex
solr.add(tmp)
File "build/bdist.linux-x86_64/egg/pysolr.py", line 779, in add
File "build/bdist.linux-x86_64/egg/pysolr.py", line 387, in _update
File "build/bdist.linux-x86_64/egg/pysolr.py", line 321, in _send_request
pysolr.SolrError: [Reason: None]
<response><lst name="responseHeader"><int name="status">400</int><int name="QTime">8</int></lst><lst name="error"><str name="msg">ERROR: [doc=...] unknown field 'title_new'</str><int name="code">400</int></lst></response>发布于 2013-12-31 09:51:58
这似乎是Solr schema.xml中的一个问题,因为异常表明"title_new“不被识别为有效字段。这个答案可能对你有帮助:https://stackoverflow.com/a/14400137/1675729
检查以确保schema.xml包含"title_new“字段,并在必要时重新启动Solr服务。如果这不能解决你的问题,回来吧!
https://stackoverflow.com/questions/20843419
复制相似问题