首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >KeyError:当尝试使用日晒将文档索引到Solr时的“id”

KeyError:当尝试使用日晒将文档索引到Solr时的“id”
EN

Stack Overflow用户
提问于 2014-11-27 07:37:00
回答 1查看 323关注 0票数 2

我试图索引几个文本文件到Solr使用晒伤。下面是我的代码

代码语言:javascript
复制
solr_url = "http://localhost:8983/solr"      
h = httplib2.Http(cache="/var/tmp/solr_cache")    
solr_instance = sunburnt.SolrInterface(url=solr_url, http_connection=h)

for url,title, webpage in webpages: 
html_id = hashlib.md5(url).hexdigest()
doc = {"id":html_id, "content":webpage, "title":title}  
solr_instance.add(doc)

try:
    solr_instance.commit()
except:
      print "Could not Commit Changes to Solr, check the log files."
else:
      print "Successfully committed changes"

但是当我运行这个程序时,我会得到错误的结果。

代码语言:javascript
复制
  File "/Users/ananya/Desktop/dbms project/code/extractText/ExtractText.py", line 94, in index_to_Solr
    solr_instance = sunburnt.SolrInterface(url=solr_url, http_connection=h)

  File "/Users/ananya/anaconda/lib/python2.7/site-packages/sunburnt/sunburnt.py", line 166, in __init__
    self.init_schema()

  File "/Users/ananya/anaconda/lib/python2.7/site-packages/sunburnt/sunburnt.py", line 177, in init_schema
    self.schema = SolrSchema(schemadoc, format=self.format)

  File "/Users/ananya/anaconda/lib/python2.7/site-packages/sunburnt/schema.py", line 417, in __init__
    if self.unique_key else None

KeyError: 'id'

我对Solr很陌生。请帮帮我。是否需要对架构文件进行任何更改?如果是,请告诉我怎么做。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-29 18:15:45

如果使用Solr4.8或更高版本,这是一个防晒伤0.6虫

arafalov的晒黑的叉子有一个补丁可以帮我修复它。

尝试:

代码语言:javascript
复制
git clone git@github.com:arafalov/sunburnt.git
cd sunburnt
python setup.py install # optionally with --user
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27165407

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档