使用不带django模型和nutch的SearchQuerySet haystack API

时间:2012-06-18 14:14:21

标签: django nutch django-haystack

早上好,

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

第一个问题是我在网站上没有任何模型,因此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。

如果有人可以提供进一步的信息或帮助我接下来要做什么,那就太好了。

由于

P.S这是我的追溯

  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'

0 个答案:

没有答案