This software offers a layer for a full-text search engine, integrating robust Sphinx and Django functionalities. It enables efficient searching of databases, with a straightforward setup and integration process.
To install the latest stable version easily, users can execute the following command: "sudo easy_install djangosphinx". However, if they prefer the latest development version, they can run "svn checkout django-sphinx" followed by "cd django-sphinx" and "sudo python setup.py install". It is also worth noting that users must install the sphinxapi.py package into their Python Path or utilize one of the included versions. To use the provided version, users need to specify the appropriate Sphinx API version in their settings.py file.
Django-Sphinx enables users to perform various search queries effortlessly. For instance, users can use the following example to explore how to employ this app:
class MyModel(models.Model):
search = SphinxSearch() # optional: defaults to db_table
# If your index name does not match MyModel._meta.db_table
# Note: You can only generate automatic configurations from the ./manage.py script
# if your index name matches.
search = SphinxSearch('index_name')
# Or maybe we want to be more.. specific
searchdelta = SphinxSearch(
index='index_name delta_name',
weights={
'name': 100,
'description': 10,
'tags': 80,
}
)
queryset = MyModel.search.query('query')
results1 = queryset.order_by('@weight', '@id', 'my_attribute')
results2 = queryset.filter(my_attribute=5)
results3 = queryset.filter(my_other_attribute=[5, 3, 4])
results4 = queryset.exclude(my_attribute=5)[0:10]
results5 = queryset.count()
Furthermore, users can access multiple additional methods like count(), extra(), all(), select_related(), group_by(), and set_options(). Users should keep in mind that the django-sphinx layer also facilitates basic querying over multiple indexes. To execute this function, users need to comprehend the rules of a UNION. Moreover, their indexes must include the same fields that also include a content_type selection correlating with the content_type id associated with that table.
Once users comprehend the rules of a UNION, they can utilize features like SphinxSearch('index1 index2 index3').query('hello') to glimpse all matches ordered by weight from all the indexes. Finally, users should bear in mind that this process executes one SQL query per index with matches in it, as Django's ORM does not support SQL UNION.
Version 2.1.2: N/A