django-haystack / django-haystack/django-haystack

Chained filters not working with Solr (2.0.0beta)

Open
#522 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backend : solr
Dominant language
Python
Stars
3.7k
Forks
1.3k
Avg merge
3h 18m
Merged PRs (30d)
3

Description

I'm using the following query:

sqs = sqs \
    .filter(members_only=members_only) \
    .filter(reservation_required=reservation_required) \
    .filter(walk_ins_welcome=walk_ins_welcome) \
    .auto_query(query) \
    .dwithin('location', center, max_dist)

Solr fails with the following error:

Failed to query Solr using '(members_only:(true) AND reservation_required:(true) AND walk_ins_welcome:(true) AND )': [Reason: None]
<html><head><meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" /><title>Error 400 org.apache.lucene.queryParser.ParseException: Cannot parse '(members_only:(true) AND reservation_required:(true) AND walk_ins_welcome:(true) AND )': Encountered " ")" ") "" at line 1, column 85.Was expecting one of:    <NOT> ...    "+" ...    "-" ...    "(" ...    "*" ...    <QUOTED> ...    <TERM> ...    <PREFIXTERM> ...    <WILDTERM> ...    "[" ...    "{" ...    <NUMBER> ...    <TERM> ...    "*" ...    </title></head><body><h2>HTTP ERROR 400</h2><p>Problem accessing /solr/select/. Reason:<pre>    org.apache.lucene.queryParser.ParseException: Cannot parse '(members_only:(true) AND reservation_required:(true) AND walk_ins_welcome:(true) AND )': Encountered " ")" ") "" at line 1, column 85.Was expecting one of:    <NOT> ...    "+" ...    "-" ...    "(" ...    "*" ...    <QUOTED> ...    <TERM> ...    <PREFIXTERM> ...    <WILDTERM> ...    "[" ...    "{" ...    <NUMBER> ...    <TERM> ...    "*" ...    </pre></p><hr /><i><small>Powered by Jetty://</small></i>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the chained filter(), auto_query(), and dwithin() calls are combined into the Solr query shown in the report. Reproduce the example against Solr and verify that the resulting query is syntactically valid and no longer produces the reported parse error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.