在没有运气的情况下从who who切换到Solr后尝试重建索引。
这些是search_indexes.py
"""Haystack search index for jobs app"""
from haystack.indexes import * #@UnusedWildImport
from haystack import site
from cthr.jobs.models import Submission
class SubmissionIndex(SearchIndex):
"""SearchIndex for job submission searching"""
text = CharField(document=True, use_template=True)
active = BooleanField(model_attr='active')
submit_date = DateTimeField(model_attr='created')
def get_queryset(self):
"""Used when the entire index for model is updated."""
return Submission.objects.all()
def get_updated_field(self):
"""Specify which field is used to calculate the age of a Submission for re-indexing"""
return 'modified'
# Wire 'em up
site.register(Submission, SubmissionIndex)
第二个是这个。
"""Haystack search index for resumes app"""
from haystack.indexes import * #@UnusedWildImport
from haystack import site
from cthr.resumes.models import Resume
class StructuredResumeIndex(SearchIndex):
"""SearchIndex for Structured Resume searching"""
text = CharField(document=True, use_template=True)
employee = BooleanField(model_attr='employee')
available = BooleanField(model_attr='available')
def get_queryset(self):
return Resume.objects.all()
def get_updated_field(self):
"""Specify which field is used to calculate the age of a Submission for re-indexing"""
return 'modified'
# Wire 'em up
site.register(Resume, StructuredResumeIndex)
这是我在运行rebuild_index时遇到的错误:
Removing all documents from your index because you said so.
DEBUG pysolr Starting request to 'http://127.0.0.1:8983/solr/update/?commit=true' (post) with body 'u'<delete>'...
INFO requests.packages.urllib3.connectionpool Starting new HTTP connection (1): 127.0.0.1
DEBUG requests.packages.urllib3.connectionpool "POST /solr/update/?commit=true HTTP/1.1" 200 None
INFO pysolr Finished 'http://127.0.0.1:8983/solr/update/?commit=true' (post) with body 'u'<delete>' in 0.357 seconds.
DEBUG pysolr Starting request to 'http://127.0.0.1:8983/solr/update/?commit=true' (post) with body 'u'<optimiz'...
INFO requests.packages.urllib3.connectionpool Starting new HTTP connection (1): 127.0.0.1
DEBUG requests.packages.urllib3.connectionpool "POST /solr/update/?commit=true HTTP/1.1" 200 None
INFO pysolr Finished 'http://127.0.0.1:8983/solr/update/?commit=true' (post) with body 'u'<optimiz' in 0.049 seconds.
All documents removed.
/usr/local/lib/python2.7/dist-packages/haystack/management/commands/update_index.py:84: UserWarning: 'SearchIndex.get_queryset' is pending deprecation & will be removed in Haystack v2. Please rename them to 'index_queryset'.
warnings.warn("'SearchIndex.get_queryset' is pending deprecation & will be removed in Haystack v2. Please rename them to 'index_queryset'.")
DEBUG django.db.backends (0.002) SELECT COUNT(*) FROM "jobs_submission"; args=()
Indexing 0 submissions.
DEBUG django.db.backends (0.000) SELECT "jobs_submission"."id" FROM "jobs_submission" ORDER BY "jobs_submission"."id" ASC; args=()
DEBUG django.db.backends (0.000) SELECT COUNT(*) FROM "resumes_resume"; args=()
Indexing 3 resumes.
DEBUG django.db.backends (0.000) SELECT "resumes_resume"."id" FROM "resumes_resume" ORDER BY "resumes_resume"."id" ASC; args=()
DEBUG django.db.backends (0.000) SELECT "resumes_resume"."id", "resumes_resume"."created", "resumes_resume"."modified", "resumes_resume"."user_id", "resumes_resume"."name", "resumes_resume"."slug", "resumes_resume"."blinded_name", "resumes_resume"."blinded_slug", "resumes_resume"."overview", "resumes_resume"."objective", "resumes_resume"."title", "resumes_resume"."employee", "resumes_resume"."available", "resumes_resume"."location", "resumes_resume"."relocation_options", "resumes_resume"."clearance", "resumes_resume"."skills_text", "resumes_resume"."email", "resumes_resume"."phone_home", "resumes_resume"."phone_mobile", "resumes_resume"."phone_work", "resumes_resume"."file" FROM "resumes_resume" ORDER BY "resumes_resume"."id" ASC LIMIT 3; args=()
DEBUG django.db.backends (0.000) SELECT "resumes_skill"."id", "resumes_skill"."skill" FROM "resumes_skill" INNER JOIN "resumes_resume_skills" ON ("resumes_skill"."id" = "resumes_resume_skills"."skill_id") WHERE "resumes_resume_skills"."resume_id" = 1 ORDER BY "resumes_skill"."skill" ASC; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_skill"."id", "resumes_skill"."skill" FROM "resumes_skill" INNER JOIN "resumes_resume_skills" ON ("resumes_skill"."id" = "resumes_resume_skills"."skill_id") WHERE "resumes_resume_skills"."resume_id" = 1 ORDER BY "resumes_skill"."skill" ASC; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_affiliation"."id", "resumes_affiliation"."resume_id", "resumes_affiliation"."affiliation" FROM "resumes_affiliation" WHERE "resumes_affiliation"."resume_id" = 1 ; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_affiliation"."id", "resumes_affiliation"."resume_id", "resumes_affiliation"."affiliation" FROM "resumes_affiliation" WHERE "resumes_affiliation"."resume_id" = 1 ; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_certification"."id", "resumes_certification"."resume_id", "resumes_certification"."certification" FROM "resumes_certification" WHERE "resumes_certification"."resume_id" = 1 ; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_certification"."id", "resumes_certification"."resume_id", "resumes_certification"."certification" FROM "resumes_certification" WHERE "resumes_certification"."resume_id" = 1 ; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_education"."id", "resumes_education"."resume_id", "resumes_education"."level", "resumes_education"."honors", "resumes_education"."discipline", "resumes_education"."minor", "resumes_education"."school", "resumes_education"."location", "resumes_education"."year" FROM "resumes_education" WHERE "resumes_education"."resume_id" = 1 ORDER BY "resumes_education"."year" DESC; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_education"."id", "resumes_education"."resume_id", "resumes_education"."level", "resumes_education"."honors", "resumes_education"."discipline", "resumes_education"."minor", "resumes_education"."school", "resumes_education"."location", "resumes_education"."year" FROM "resumes_education" WHERE "resumes_education"."resume_id" = 1 ORDER BY "resumes_education"."year" DESC; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_publication"."id", "resumes_publication"."resume_id", "resumes_publication"."publication" FROM "resumes_publication" WHERE "resumes_publication"."resume_id" = 1 ; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_publication"."id", "resumes_publication"."resume_id", "resumes_publication"."publication" FROM "resumes_publication" WHERE "resumes_publication"."resume_id" = 1 ; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_jobhistory"."id", "resumes_jobhistory"."resume_id", "resumes_jobhistory"."title", "resumes_jobhistory"."company", "resumes_jobhistory"."location", "resumes_jobhistory"."date_from", "resumes_jobhistory"."date_to", "resumes_jobhistory"."description", "resumes_jobhistory"."skills_text" FROM "resumes_jobhistory" WHERE "resumes_jobhistory"."resume_id" = 1 ORDER BY "resumes_jobhistory"."date_from" DESC; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_jobhistory"."id", "resumes_jobhistory"."resume_id", "resumes_jobhistory"."title", "resumes_jobhistory"."company", "resumes_jobhistory"."location", "resumes_jobhistory"."date_from", "resumes_jobhistory"."date_to", "resumes_jobhistory"."description", "resumes_jobhistory"."skills_text" FROM "resumes_jobhistory" WHERE ("resumes_jobhistory"."resume_id" = 1 AND "resumes_jobhistory"."date_to" IS NULL) ORDER BY "resumes_jobhistory"."date_from" DESC; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_jobhistory"."id", "resumes_jobhistory"."resume_id", "resumes_jobhistory"."title", "resumes_jobhistory"."company", "resumes_jobhistory"."location", "resumes_jobhistory"."date_from", "resumes_jobhistory"."date_to", "resumes_jobhistory"."description", "resumes_jobhistory"."skills_text" FROM "resumes_jobhistory" WHERE ("resumes_jobhistory"."resume_id" = 1 AND "resumes_jobhistory"."date_to" IS NOT NULL) ORDER BY "resumes_jobhistory"."date_to" DESC; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_skill"."id", "resumes_skill"."skill" FROM "resumes_skill" INNER JOIN "resumes_jobhistory_skills" ON ("resumes_skill"."id" = "resumes_jobhistory_skills"."skill_id") WHERE "resumes_jobhistory_skills"."jobhistory_id" = 1 ORDER BY "resumes_skill"."skill" ASC; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_skill"."id", "resumes_skill"."skill" FROM "resumes_skill" INNER JOIN "resumes_jobhistory_skills" ON ("resumes_skill"."id" = "resumes_jobhistory_skills"."skill_id") WHERE "resumes_jobhistory_skills"."jobhistory_id" = 1 ORDER BY "resumes_skill"."skill" ASC; args=(1,)
DEBUG django.db.backends (0.000) SELECT "resumes_skill"."id", "resumes_skill"."skill" FROM "resumes_skill" INNER JOIN "resumes_resume_skills" ON ("resumes_skill"."id" = "resumes_resume_skills"."skill_id") WHERE "resumes_resume_skills"."resume_id" = 2 ORDER BY "resumes_skill"."skill" ASC; args=(2,)
DEBUG django.db.backends (0.000) SELECT "resumes_skill"."id", "resumes_skill"."skill" FROM "resumes_skill" INNER JOIN "resumes_resume_skills" ON ("resumes_skill"."id" = "resumes_resume_skills"."skill_id") WHERE "resumes_resume_skills"."resume_id" = 2 ORDER BY "resumes_skill"."skill" ASC; args=(2,)
DEBUG django.db.backends (0.000) SELECT "resumes_affiliation"."id", "resumes_affiliation"."resume_id", "resumes_affiliation"."affiliation" FROM "resumes_affiliation" WHERE "resumes_affiliation"."resume_id" = 2 ; args=(2,)
DEBUG django.db.backends (0.000) SELECT "resumes_certification"."id", "resumes_certification"."resume_id", "resumes_certification"."certification" FROM "resumes_certification" WHERE "resumes_certification"."resume_id" = 2 ; args=(2,)
DEBUG django.db.backends (0.000) SELECT "resumes_education"."id", "resumes_education"."resume_id", "resumes_education"."level", "resumes_education"."honors", "resumes_education"."discipline", "resumes_education"."minor", "resumes_education"."school", "resumes_education"."location", "resumes_education"."year" FROM "resumes_education" WHERE "resumes_education"."resume_id" = 2 ORDER BY "resumes_education"."year" DESC; args=(2,)
DEBUG django.db.backends (0.000) SELECT "resumes_publication"."id", "resumes_publication"."resume_id", "resumes_publication"."publication" FROM "resumes_publication" WHERE "resumes_publication"."resume_id" = 2 ; args=(2,)
DEBUG django.db.backends (0.000) SELECT "resumes_jobhistory"."id", "resumes_jobhistory"."resume_id", "resumes_jobhistory"."title", "resumes_jobhistory"."company", "resumes_jobhistory"."location", "resumes_jobhistory"."date_from", "resumes_jobhistory"."date_to", "resumes_jobhistory"."description", "resumes_jobhistory"."skills_text" FROM "resumes_jobhistory" WHERE "resumes_jobhistory"."resume_id" = 2 ORDER BY "resumes_jobhistory"."date_from" DESC; args=(2,)
DEBUG django.db.backends (0.000) SELECT "resumes_skill"."id", "resumes_skill"."skill" FROM "resumes_skill" INNER JOIN "resumes_resume_skills" ON ("resumes_skill"."id" = "resumes_resume_skills"."skill_id") WHERE "resumes_resume_skills"."resume_id" = 3 ORDER BY "resumes_skill"."skill" ASC; args=(3,)
DEBUG django.db.backends (0.000) SELECT "resumes_affiliation"."id", "resumes_affiliation"."resume_id", "resumes_affiliation"."affiliation" FROM "resumes_affiliation" WHERE "resumes_affiliation"."resume_id" = 3 ; args=(3,)
DEBUG django.db.backends (0.000) SELECT "resumes_certification"."id", "resumes_certification"."resume_id", "resumes_certification"."certification" FROM "resumes_certification" WHERE "resumes_certification"."resume_id" = 3 ; args=(3,)
DEBUG django.db.backends (0.000) SELECT "resumes_education"."id", "resumes_education"."resume_id", "resumes_education"."level", "resumes_education"."honors", "resumes_education"."discipline", "resumes_education"."minor", "resumes_education"."school", "resumes_education"."location", "resumes_education"."year" FROM "resumes_education" WHERE "resumes_education"."resume_id" = 3 ORDER BY "resumes_education"."year" DESC; args=(3,)
DEBUG django.db.backends (0.000) SELECT "resumes_publication"."id", "resumes_publication"."resume_id", "resumes_publication"."publication" FROM "resumes_publication" WHERE "resumes_publication"."resume_id" = 3 ; args=(3,)
DEBUG django.db.backends (0.000) SELECT "resumes_jobhistory"."id", "resumes_jobhistory"."resume_id", "resumes_jobhistory"."title", "resumes_jobhistory"."company", "resumes_jobhistory"."location", "resumes_jobhistory"."date_from", "resumes_jobhistory"."date_to", "resumes_jobhistory"."description", "resumes_jobhistory"."skills_text" FROM "resumes_jobhistory" WHERE "resumes_jobhistory"."resume_id" = 3 ORDER BY "resumes_jobhistory"."date_from" DESC; args=(3,)
DEBUG pysolr Starting to build add request...
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 459, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/haystack/management/commands/rebuild_index.py", line 16, in handle
call_command('update_index', **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 150, in call_command
return klass.execute(*args, **defaults)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/haystack/management/commands/update_index.py", line 193, in handle
return super(Command, self).handle(*apps, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 304, in handle
app_output = self.handle_app(app, **options)
File "/usr/local/lib/python2.7/dist-packages/haystack/management/commands/update_index.py", line 229, in handle_app
do_update(index, qs, start, end, total, self.verbosity)
File "/usr/local/lib/python2.7/dist-packages/haystack/management/commands/update_index.py", line 109, in do_update
index.backend.update(index, current_qs)
File "/usr/local/lib/python2.7/dist-packages/haystack/backends/solr_backend.py", line 73, in update
self.conn.add(docs, commit=commit, boost=index.get_field_weights())
File "/usr/local/lib/python2.7/dist-packages/pysolr.py", line 740, in add
message.append(self._build_doc(doc, boost=boost))
File "/usr/local/lib/python2.7/dist-packages/pysolr.py", line 695, in _build_doc
field = ET.Element('field', **attrs)
File "lxml.etree.pyx", line 2560, in lxml.etree.Element (src/lxml/lxml.etree.c:52924)
TypeError: Element() keywords must be strings
我不确定我做错了什么,从我看到的和google搜索它告诉我,我正在传递unicode而它需要一个字符串?
谢谢。
答案 0 :(得分:3)
我遇到了这个问题而且我已经解决了这个问题。
看看这个问题的答案:
你是如何安装lxml
的?我做了什么,我去了/usr/local/lib/python2.7/dist-packages
并删除了lxml
目录,并从上面的链接运行命令:
apt-get install libxml2-dev libxslt-dev
然后问题就消失了。
答案 1 :(得分:2)