Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing SearchQuerySet haystack API without django models and nutch
    primarykey
    data
    text
    <p>Morning all,</p> <p>This past week I have been experimenting with different search engines and indexing tools and have come across a problem. I have a django site that is all static pages. I have used nutch to scrape the site and send the results to a solr index. I would like to use haystack for getting the results of the search, but I have run into a few problems.</p> <p>The first problem is that I do not have any models in the site, and therefor the tutorial that haystack has set up is useless. I already have the index set up in solr and would just like to use the SearchQuerySet API to search it.</p> <p>The first thing I tried was adding these lines to the solr index to get it to work:</p> <pre><code> &lt;field name="id" type="string" stored="true" indexed="true" multiValued="false" required="true"/&gt; &lt;field name="django_ct" type="string" indexed="true" stored="true" multiValued="false"/&gt; &lt;field name="django_id" type="string" indexed="true" stored="true" multiValued="false"/&gt; </code></pre> <p>However, after that, when I try to use the API to search, I get the following error on the django page:</p> <pre><code> "KeyError at /search/" 'django_ct' </code></pre> <p>I've heard from people, that you have to add those keys to the schema.xml in solr in order to be able to use the SearchQuerySet without having models.</p> <p>If someone could provide further information or help on what I should do next, that would be great.</p> <p>Thanks</p> <p>P.S here is my traceback</p> <pre><code> 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('.') </code></pre> <p>Exception Type: KeyError at /search/ Exception Value: 'django_ct'</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload