Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Converts arbitrarily complicated user entered query strings to a haystack query object.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 haystack_queryparser
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 README.md
Octocat-spinner-32 setup.cfg
Octocat-spinner-32 setup.py
README.md

haystack-queryparser

Converts arbitrarily complicated user entered query strings to a haystack query object. http://aplopio.github.io/haystack-queryparser

Usage

  from haystack_queryparser import ParseSQ

Also provides or_parser and and_parser which can be directly used with a query

  parser = ParseSQ() 
  sq_object = parser.parse(query)

takes a AND or OR operator to use as default optionally.

Input

Input should be a string.This the query.

Output

Output is a SQ(haystack.query.SQ) object. This can be passed to SearchQuerySet.filter and the query will be applied

Test

To run the test you need to be in the django environment.So you can do something like this:

$ python manage.py shell
>>> import haystack_queryparser.tests as test
>>> tests.main()
test_operators (modules.haystack_queryparser2.tests.SimpleTest) ... ok
test_parse (modules.haystack_queryparser2.tests.SimpleTest) ... ok
test_parse_with_new_default (modules.haystack_queryparser2.tests.SimpleTest) ... ok

----------------------------------------------------------------------
Ran 3 tests in 0.004s

OK
Something went wrong with that request. Please try again.