2

I'm using django and haystack with whoosh and I have several questions about them:

1) When I attempt to search smth I should select all models which has indexed in whoosh. How can I set system to find values everywhere (on all models)?

2) I have search input box but it doesn't work with haystack urls. So my template (I'm using bootstrap):

<form  method="get" action="/search/" class="navbar-search pull-left">
   <input type="text" class="search-query" placeholder="Search">
</form>

And I have search url like in tutorial:

(r'^search/', include('haystack.urls')),

How say this form to start search immidiately and sends data to haystack?

kurd
  • 467
  • 1
  • 10
  • 18

2 Answers2

0

For part 2,

since haystack uses ?q= to get queries, you should put name="q" into the input field,

<form  method="get" action="/search/" class="navbar-search pull-left">
    <input name="q" type="text" class="search-query" placeholder="Search">
</form>

For part 1,

you can put in search_indexes.py into each model folder. Not sure if there is more efficient method. You can use ModelSearchView if you want to give users a choice to search which models.

DavidL
  • 1,260
  • 2
  • 17
  • 35
0

You need to create RealTimeSearchIndex classes in your search_index.py file in the project root, and register these indexes with haystack.

Then you need to reindex your data using the haystack manage.py reindex command.

Then you need to provide a template for the search page that haystack will generate.

Keep reading the docs, it's all there.

Thomas
  • 11,757
  • 4
  • 41
  • 57