我用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
但这个不能:
^{pr2}$有什么想法吗?在
编辑:
以下是例外:
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>
你的Solr好像有问题架构.xml,因为异常表明“title_new”未被识别为有效字段。这个答案可能对你有帮助:https://stackoverflow.com/a/14400137/1675729
检查以确保架构.xml包含一个“title\u new”字段,如果需要,您已经重新启动了Solr服务。如果这不能解决你的问题,回来吧!在
相关问题 更多 >
编程相关推荐