Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete #30

Open
sebfie opened this issue Jul 25, 2011 · 2 comments
Open

Autocomplete #30

sebfie opened this issue Jul 25, 2011 · 2 comments

Comments

@sebfie
Copy link

sebfie commented Jul 25, 2011

Hello,

I want to do an autocompletion with django-sphinx but i failed. How can I activate the match mode? I read the doc but i didn't understand how to implement it.

Thank you

@dbrgn
Copy link

dbrgn commented Aug 3, 2011

Hi Ditchou. I created an Autocomplete by using a prefixed Sphinx index and using the SPH_MATCH_EXTENDED2 mode.

sphinx.conf:

index persons_prefixed
{
  source          = persons
  path            = /var/sphinx/data/persons_prefixed
  docinfo         = extern
  charset_type = utf-8
  enable_star = 1 
  prefix_fields = name, place
  min_prefix_len = 2 
}

models.py:

class Person(models.Mode):
    ...
    search_prefixed = SphinxSearch(
        index = u'persons_prefixed',
        mode = u'SPH_MATCH_EXTENDED2',
    )
    ...

Then I used a search string like @(name) foo bar* to search the name field for a string beginning with "foo bar".

q = '@(name) foo bar*'  # generate your query here, instead of hardcoding it
persons = models.Person.search_prefixed.query(q)

You can then handle the output objects.

@sebfie
Copy link
Author

sebfie commented Aug 5, 2011

Thank a lot, i will try this this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants