{ "info": { "author": "Jorge C. Leit\u00e3o", "author_email": "jorgecarleitao@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Utilities" ], "description": "[![Build Status](https://travis-ci.org/jorgecarleitao/django-sphinxql.svg?branch=master)](https://travis-ci.org/jorgecarleitao/django-sphinxql)\n[![Coverage Status](https://coveralls.io/repos/jorgecarleitao/django-sphinxql/badge.svg?branch=master&service=github)](https://coveralls.io/github/jorgecarleitao/django-sphinxql?branch=master)\n\nDjango-SphinxQL implements [Sphinx search](http://sphinxsearch.com) for\n[Django](https://www.djangoproject.com), thanks for checking it out.\n\nDjango is a Web framework for building websites with relational databases;\nSphinx is a search engine designed for relational databases.\nDjango-SphinxQL defines an ORM for using **Sphinx in Django**.\nAs corollary, it allows you to implement full text search with Sphinx in your\nDjango website.\n\nSpecifically, this API allows you to:\n\n1. Configure Sphinx with Python.\n2. Index Django models in Sphinx.\n3. Execute Sphinx queries (SphinxQL) using Django-like expressions and have the \nresults as Django models.\n\nDjango-SphinxQL requires:\n\n- Python 3\n- pymysql\n- Django (>=1.8)\n- Sphinx\n- A backend (pymysql or psycopg2)\n\nOur build matrix in Travis has 8 builds:\n\n- Python 3.4\n- Django 1.8 and 1.10\n- Sphinx 2.2.10 and 2.2.11\n- mysql and postgres backends\n\nFor more details, you can check the directory `tests` and `.travis.yml`.\n\nTo run the tests locally, use:\n\n PYTHONPATH=..:$PYTHONPATH django-admin.py test --settings=tests.settings_test tests\n\nThe next sections present a minimal setup to use this package. The full documentation\nis available [here](http://django-sphinxql.readthedocs.org/en/latest/).\n\nInstallation\n------------\n\nDjango-SphinxQL has no requirements besides Django and Sphinx. To install Sphinx,\nuse:\n\n export VERSION=2.2.10\n wget http://sphinxsearch.com/files/sphinx-$VERSION-release.tar.gz\n tar -xf sphinx-$VERSION-release.tar.gz\n cd sphinx-$VERSION-release\n ./configure --prefix=$HOME --with-pgsql\n make\n make install\n\nTo install Django-SphinxQL, use:\n\n pip install git+https://github.com/jorgecarleitao/django-sphinxql.git\n\nMinimal configuration\n---------------------\n\nDjango-SphinxQL requires a directory to store its database and be registered as\ninstalled app (it doesn't contain Django models):\n\n1. add `sphinxql` to the ``INSTALLED_APPS``;\n2. add ``INDEXES`` to settings:\n\n INDEXES = {\n 'path': os.path.join(BASE_DIR, '_index'), # also do `mkdir _index`.\n 'sphinx_path': BASE_DIR\n }\n\n- ``path`` is where Sphinx database is going to be created\n- ``sphinx_path`` is the directory that will contain Sphinx-specific files.\n\nIndex your models\n-----------------\n\nAssume you have a model ``Document`` with a ``summary``, a ``text`` and a\n``number`` that you want to index. To index it, create a file ``indexes.py`` in \nyour app with:\n\n from sphinxql import indexes, fields\n from myapp import models\n\n class DocumentIndex(indexes.Index):\n my_summary = fields.Text(model_attr='summary')\n my_text = fields.Text(model_attr='text')\n my_number = fields.Integer(model_attr='number')\n\n class Meta:\n model = models.Document\n\n`model_attr` can be either a string with lookups or an [F expression](https://docs.djangoproject.com/en/1.8/topics/db/queries/#using-f-expressions-in-filters).\nE.g. `type_name = fields.Text(model_attr='type__name')` will index the name of\nthe ForeignKey `type` of your model, while \n\n type_name = fields.Text(model_attr=Concat('type__name', Value(' '),\n 'my_text',\n output_field=CharField()))\n\nindexes the concatenation of two fields (see also [Django documentation](https://docs.djangoproject.com/en/dev/ref/models/database-functions/#concat)).\nIn principle the index fields accept any Django expression Django annotate accepts.\n\nTo index your indexes, run:\n\n python manage.py index_sphinx\n\nAt this moment you may notice that some files will be created in\n``settings.INDEXES['path']``: Sphinx database is populated.\n\nThen, start Sphinx daemon (only has to be started once):\n\n python manage.py start_sphinx\n\n(for the sake of reversibility, to stop Sphinx use ``python manage.py stop_sphinx``)\n\nSearch your indexes\n-------------------\n\nDjango-SphinxQL defines a subclass of Django ``QuerySet``'s, that interfaces with\nall Sphinx-related operations. ``SearchQuerySet`` *only adds functionality*: if you\ndon't use Sphinx-related, it is a ``QuerySet``.\n\nSphinx has a dedicated syntax for text search that Django-SphinxQL also accepts:\n\n >>> q = SearchQuerySet(DocumentIndex).search('@my_text toys for babies')\n\nThis particular query returns ``Documents`` restricted to the ones where\n\"toys for babies\" match in field ``my_text``, ordered by the most relevant match.\nOnce you perform it, it does the following:\n\n1. hit Sphinx database and convert results to ``DocumentIndex`` instances;\n2. hit Django database to retrieve the respective ``Document`` instances;\n3. annotate ``Document`` instances with the respective ``DocumentIndex``\n instances (in attribute ``search_result``)\n4. returns the ``Document`` instances.\n\nStep 2. is done using ``.filter(pk__in=[...])``. The results are ordered by relevance\nbecause there was no specific call of ``order_by``: if you set any ordering\nin Django Query, it uses Django ordering (i.e. it overrides the default ordering\nbut not an explicit ordering). See docs for detailed information.\n\nKnown limitations\n-----------------\n\n* Null values are considered empty strings or 0 (constraint on Sphinx engine)\n* Only supports dates and times since 1970 (constraint on Sphinx engine)\n* Most Sphinx functionality *is not* implemented, notably real time indexes.\n\nFinal note\n----------\n\nYou should check if [Django-Haystack](http://haystacksearch.org/) suits your needs.\n\nDjango-SphinxQL is useful when you can index your data on a time-scale\ndifferent from \"real time\". It should be much faster in indexing, and it should\nhave lower memory requirements.\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jorgecarleitao/django-sphinxql", "keywords": "", "license": "GPLv2", "maintainer": "", "maintainer_email": "", "name": "django-sphinxql", "package_url": "https://pypi.org/project/django-sphinxql/", "platform": "", "project_url": "https://pypi.org/project/django-sphinxql/", "project_urls": { "Homepage": "https://github.com/jorgecarleitao/django-sphinxql" }, "release_url": "https://pypi.org/project/django-sphinxql/1.1.0/", "requires_dist": null, "requires_python": "", "summary": "Sphinx search on Django", "version": "1.1.0" }, "last_serial": 2694053, "releases": { "1.1.0": [ { "comment_text": "", "digests": { "md5": "e40d090a9bbeeae69bbdbd5f16fb9692", "sha256": "e63282ff4c4c778528ce6c78ee88b7e37be18c0a36ed4ea4503e0b76c0309fb5" }, "downloads": -1, "filename": "django-sphinxql-1.1.0.tar.gz", "has_sig": false, "md5_digest": "e40d090a9bbeeae69bbdbd5f16fb9692", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28866, "upload_time": "2017-03-09T13:50:49", "url": "https://files.pythonhosted.org/packages/71/1e/28ed9a15d35157ff0fa420e9e1c6013a0607686cf9785a22b2b5b3fd8636/django-sphinxql-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e40d090a9bbeeae69bbdbd5f16fb9692", "sha256": "e63282ff4c4c778528ce6c78ee88b7e37be18c0a36ed4ea4503e0b76c0309fb5" }, "downloads": -1, "filename": "django-sphinxql-1.1.0.tar.gz", "has_sig": false, "md5_digest": "e40d090a9bbeeae69bbdbd5f16fb9692", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28866, "upload_time": "2017-03-09T13:50:49", "url": "https://files.pythonhosted.org/packages/71/1e/28ed9a15d35157ff0fa420e9e1c6013a0607686cf9785a22b2b5b3fd8636/django-sphinxql-1.1.0.tar.gz" } ] }