Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Internet > HTTP (WWW)

    django-sphinx 2.2.4

    Download button

    No screenshots available
    Downloads: 684  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    David Cramer | More programs
    BSD License / FREE
    April 19th, 2011, 14:14 GMT
    ROOT / Internet / HTTP (WWW)

     Read user reviews (0)  Refer to a friend  Subscribe

    django-sphinx description

    A layer for full-text search engine using Sphinx and Django

    django-sphinx is a layer that functions much like the Django ORM does except it works on top of the Sphinx full-text search engine.

    Please Note: You will need to create your own sphinx indexes and install sphinx on your server to use this app.

    There will no longer be release packages available. Please use SVN to checkout the latest trunk version, as it should always be stable and current.

    Install:


    To install the latest stable version:

    sudo easy_install djangosphinx

    To install the latest development version (updated quite often):

    svn checkout http://django-sphinx.googlecode.com/svn/trunk/ django-sphinx
    cd django-sphinx

    sudo python setup.py install

    Note: You will need to install the sphinxapi.py package into your Python Path or use one of the included versions. To use the included version, you must specify the following in your settings.py file:

    # Sphinx 0.9.9
    SPHINX_API_VERSION = 0x116

    # Sphinx 0.9.8
    SPHINX_API_VERSION = 0x113

    # Sphinx 0.9.7
    SPHINX_API_VERSION = 0x107


    Usage:


    The following is some example usage:

    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()

    # as of 2.0 you can now access an attribute to get the weight and similar arguments
    for result in results1:
     print result, result._sphinx
    # you can also access a similar set of meta data on the queryset itself (once it's been sliced or executed in any way)
    print results1._sphinx


    Some additional methods:

     * count()
     * extra() (passed to the queryset)
     * all() (does nothing)
     * select_related() (passed to the queryset)
     * group_by(field, field, field)
     * set_options(index='', weights={}, weights=[])

    The django-sphinx layer also supports some basic querying over multiple indexes. To use this you first need to understand the rules of a UNION. Your indexes must contain exactly the same fields. These fields must also include a content_type selection which should be the content_type id associated with that table (model).

    You can then do something like this:

    SphinxSearch('index1 index2 index3').query('hello')

    This will return a list of all matches, ordered by weight, from all indexes. This performs one SQL query per index with matches in it, as Django's ORM does not support SQL UNION.


    Product's homepage

    Requirements:

    · Django
    · Python

      


    TAGS:

    full-text search | search engine | Django plugin | Django | Sphinx | full-text

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM