2

大家早,

在过去的一周里,我一直在尝试不同的搜索引擎和索引工具,但遇到了一个问题。我有一个全是静态页面的 django 站点。我使用 nutch 抓取网站并将结果发送到 solr 索引。我想使用 haystack 来获取搜索结果,但我遇到了一些问题。

第一个问题是我的站点没有任何模型,因此干草堆设置的教程没有用。我已经在 solr 中设置了索引,只想使用 SearchQuerySet API 来搜索它。

我尝试的第一件事是将这些行添加到 solr 索引以使其工作:

    <field name="id" type="string" stored="true" indexed="true" multiValued="false" required="true"/>
    <field name="django_ct" type="string" indexed="true" stored="true" multiValued="false"/>
    <field name="django_id" type="string" indexed="true" stored="true" multiValued="false"/>

但是,之后,当我尝试使用 API 进行搜索时,在 django 页面上出现以下错误:

   "KeyError at /search/" 'django_ct'

我从人们那里听说,您必须将这些键添加到 solr 中的 schema.xml 才能在没有模型的情况下使用 SearchQuerySet。

如果有人可以提供更多信息或帮助我下一步应该做什么,那就太好了。

谢谢

PS这是我的回溯

  Traceback:
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  136.                     response = response.render()
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/response.py" in render
  104.             self._set_content(self.rendered_content)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/response.py" in rendered_content
  81.         content = template.render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in render
  140.             return self._render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in render
  823.                 bit = self.render_node(node, context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in render_node
  837.         return node.render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  123.         return compiled_parent._render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in render
  823.                 bit = self.render_node(node, context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in render_node
  837.         return node.render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  123.         return compiled_parent._render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in render
  823.                 bit = self.render_node(node, context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in render_node
  837.         return node.render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  62.             result = block.nodelist.render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in render
  823.                 bit = self.render_node(node, context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in render_node
  837.         return node.render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  62.             result = block.nodelist.render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in render
  823.                 bit = self.render_node(node, context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in render_node
  837.         return node.render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  62.             result = block.nodelist.render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in render
  823.                 bit = self.render_node(node, context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/base.py" in render_node
  837.         return node.render(context)
  File "/home/dave/virtualenvs/stuff/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
  145.         len_values = len(values)
  File "/home/dave/virtualenvs/stuff/src/stuff/haystack/query.py" in __len__
  84.             self._result_count = self.query.get_count()
  File "/home/dave/virtualenvs/stuff/src/stuff/haystack/backends/__init__.py" in get_count
  459.                 self.run()
  File "/home/dave/virtualenvs/stuff/src/stuff/haystack/backends/solr_backend.py" in run
  667.         results = self.backend.search(final_query, **search_kwargs)
  File "/home/dave/virtualenvs/stuff/src/stuff/haystack/backends/__init__.py" in wrapper
  27.             return func(obj, query_string, *args, **kwargs)
  File "/home/dave/virtualenvs/stuff/src/stuff/haystack/backends/solr_backend.py" in search
  257.         return self._process_results(raw_results, highlight=highlight, result_class=result_class, distance_point=distance_point)
  File "/home/dave/virtualenvs/stuff/src/stuff/haystack/backends/solr_backend.py" in _process_results
  355.             app_label, model_name = raw_result[DJANGO_CT].split('.')

异常类型:/search/ 处的 KeyError 异常值:'django_ct'

4

0 回答 0