Skip to main content
GitHub Actions https://coveralls.io/repos/notanumber/xapian-haystack/badge.svg?branch=master&service=github PyPI version

Xapian-haystack is a backend of Django-Haystack for the Xapian search engine. Thanks for checking it out.

You can find more information about Xapian here.

Features

Xapian-Haystack provides all the standard features of Haystack:

  • Weighting

  • Faceted search (date, query, etc.)

  • Sorting

  • Spelling suggestions

  • EdgeNGram and Ngram (for autocomplete)

Limitations

The endswith search operation is not supported by Xapian-Haystack.

Requirements

  • Python 3+

  • Django 2.2+

  • Django-Haystack 2.8.0

  • Xapian 1.4+

Installation

First, install Xapian in your machine e.g. with the script provided, install_xapian.sh. Call it after activating the virtual environment to install:

source <path>/bin/activate
./install_xapian.sh <version>

<version> must be >=1.4.0. This takes around 10 minutes.

Finally, install Xapian-Haystack by running:

pip install xapian-haystack

Configuration

Xapian is configured as other backends of Haystack. You have to define the connection to the database, which is done to a path to a directory, e.g:

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'xapian_backend.XapianEngine',
        'PATH': os.path.join(os.path.dirname(__file__), 'xapian_index')
    },
}

The backend has the following optional settings:

  • HAYSTACK_XAPIAN_LANGUAGE: the stemming language; the default is english and the list of available languages can be found here.

  • HAYSTACK_XAPIAN_WEIGHTING_SCHEME: a tuple with parameters to be passed to the weighting scheme BM25. By default, it uses the same parameters as Xapian recommends; this setting allows you to change them.

  • HAYSTACK_XAPIAN_FLAGS: the options used to parse AutoQueries; the default is FLAG_PHRASE | FLAG_BOOLEAN | FLAG_LOVEHATE | FLAG_WILDCARD | FLAG_PURE_NOT See here for more information on what they mean.

  • HAYSTACK_XAPIAN_STEMMING_STRATEGY: This option lets you chose the stemming strategy used by Xapian. Possible values are STEM_NONE, STEM_SOME, STEM_ALL, STEM_ALL_Z, where STEM_SOME is the default. See here for more information about the different strategies.

  • XAPIAN_NGRAM_MIN_LENGTH, XAPIAN_NGRAM_MAX_LENGTH: options for custom configuration of ngrams (phrases) length.

  • HAYSTACK_XAPIAN_USE_LOCKFILE: Use a lockfile to prevent database locking errors when running management commands with multiple workers. Defaults to True.

Testing

Xapian-Haystack has a test suite in continuous deployment with GitHub Actions. The file .github/workflows/test.yml contains the steps required to run the test suite.

Source

The source code can be found in github.

Credits

Xapian-Haystack is maintained by Jorge C. Leitão; David Sauve was the main contributor of Xapian-Haystack and Xapian-Haystack was originally funded by Trapeze. Claude Paroz is a frequent contributor. ANtlord implemented support for EdgeNgram and Ngram.

License

Xapian-haystack is free software licenced under GNU General Public Licence v2 and Copyright (c) 2009, 2010, 2011, 2012 David Sauve, 2009, 2010 Trapeze, 2014 Jorge C. Leitão. It may be redistributed under the terms specified in the LICENSE file.

Questions, Comments, Concerns:

Feel free to open an issue here or pull request your work.

You can ask questions on the django-haystack mailing list: or in the irc #haystack.

Metadata

Release files for xapian-haystack 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xapian-haystack 4.0.0
File Size Uploaded
xapian_haystack-4.0.0.tar.gz 41.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xapian-haystack 4.0.0
File Interpreter ABI Platform
xapian_haystack-4.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 65.8 kB

Release files / xapian_haystack-4.0.0.tar.gz

Download URL xapian_haystack-4.0.0.tar.gz
Size 41.2 kB
Tags Source
SHA-256 checksum
How to use checksums
db4917cace93ecf3f321b96f974e4f0798936e1f883a2ab17f14112d3bfede0c
BLAKE2b-256 checksum
How to use checksums
4765d947ed25472b5c32011d9f750f3969c82f80e68243a88b3241fd002f6ba4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / xapian_haystack-4.0.0-py3-none-any.whl

Download URL xapian_haystack-4.0.0-py3-none-any.whl
Size 24.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e9a0a6a2a59402c2f1411b803c2b769f1abb085fb30b49e2b9f43e3b642850c3
BLAKE2b-256 checksum
How to use checksums
2db4303c3a31a0d110a898b393d1092afd2b9d9b18d1ace18a1c30b6bb4c8fe4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page