pombreda / djapian

Automatically exported from code.google.com/p/djapian
Other
0 stars 0 forks source link

search using djapian indexing and other issues #110

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I ve few issues in implimenting the django djapian search for our website 
it shows me an error saying global name 'complete_indexer' is not defined
my forms.py is:
lass Studio(forms.Form):
       name=forms.Field(widget=forms.TextInput(),label=_(u'Title:Listing 
Details'))

class Person(forms.Form):
       name=forms.Field(widget=forms.TextInput(),label=_(u'Title:Listing 
Details'))

class Movie(forms.Form):
       name=forms.Field(widget=forms.TextInput(),label=_(u'Title:Listing 
Details'))

MODEL_MAP = {
    'studio': Studio,
    'person': Person,
    'movie': Movie
}

MODEL_CHOICES = [('', 'all')] + zip(MODEL_MAP.keys(), MODEL_MAP.keys())

class SearchForm(forms.Form):
    query = forms.CharField(required=True)
    model = forms.ChoiceField(choices=MODEL_CHOICES, required=False)
my Views.py is:
def search_dja(request):

    results = []
    print results
    if request.GET:
        form = SearchForm(request.GET)

        if form.is_valid():
            query = form.cleaned_data['query']
            model = MODEL_MAP.get(form.cleaned_data['model'])

            if not model:
                indexer = complete_indexer(CompositeIndexer(*indexer))
            else:
                indexer = model.indexer
            results = indexer.search(query).prefetch()

    else:
        form = SearchForm()

    return render_to_response('app_manager/searchdja.html', 
{'results':results,'form': form})
My urls.py is:
(r'^searchdj/', search_dja),

my question is that how do i import the complete_indexer in django and how 
it works any boby pl help in this issue

Original issue reported on code.google.com by krnsha...@gmail.com on 10 Apr 2010 at 6:05

GoogleCodeExporter commented 9 years ago

Original comment by daevaorn on 10 Apr 2010 at 6:59

GoogleCodeExporter commented 9 years ago

Original comment by daevaorn on 10 Apr 2010 at 7:00

GoogleCodeExporter commented 9 years ago
Please go through the Djapian tutorial again.

Here http://code.google.com/p/djapian/wiki/Tutorial#Creating_indexers we 
declare 

complete_indexer = CompositeIndexer(Studio.indexer, Movie.indexer, 
Person.indexer)

at the bottom of the index.py file, and here 
http://code.google.com/p/djapian/wiki/Tutorial#Writing_search_view

we import it in the views.py file:

from movies.index import complete_indexer
...

Original comment by esizi...@gmail.com on 24 Jun 2010 at 8:11

GoogleCodeExporter commented 9 years ago

Original comment by esizi...@gmail.com on 21 Oct 2011 at 7:52