Question On Haystack 2 and LocalParams

104 views
Skip to first unread message

KRH

unread,
Feb 27, 2012, 4:40:04 PM2/27/12
to django-haystack
I'm trying to use LocalParams on a query, to specify dismax behavior
for it. However, it seems like Haystack is malforming the query. The
python:

sqs = SearchQuerySet().filter(content=AltParser('edismax',
qf='text^0.5 trait^1.5 name^2.0 display_name^2.0', mm=1))
sqs = sqs.auto_query('my awesome query')

Putting a print statement in Haystack's solr backend, I see this come
out as the query string:

({!edismax mm=1 qf='text^0.5 trait^1.5 name^2.0 display_name^2.0'} AND
my awesome query)

This throws a Solr error:

Failed to query Solr using '({!edismax mm=1 qf='text^0.5 trait^1.5
name^2.0 display_name^2.0'} AND my awesome query)': [Reason:
org.apache.lucene.queryParser.ParseException: Cannot parse '({!edismax
mm=1 qf='text^0.5 trait^1.5 name^2.0 display_name^2.0'} AND my awesome
query)': Encountered " <RANGEEX_GOOP> "qf=\'text^0.5
"" at line 1, column 16.
Was expecting:
"}" ...
]

I believe the way the query needs to be formatted is this way: {!
edismax mm=1 qf='text^0.5 trait^1.5 name^2.0 display_name^2.0'}(my
awesome query)

Plugging that directly into Solr yields a valid query. So it seems
like Haystack is treating the LocalParams as its own query statement
and trying to chain it into the main query. I've also tried putting
the LocalParams in with the Raw input type and gotten the same result.
Is this a bug in Haystack or is there another way for me to do this?

Kevin Sparks

unread,
May 2, 2012, 5:33:34 PM5/2/12
to django-...@googlegroups.com
Hi KRH,

Did you ever discover a solution for this?  I need to be able to specify some LocalParams in my query and it too is breaking the Solr/Lucene syntax by wrapping brackets around the query.  I've found the culprit on line 592 or haystack/backends/solr_backend.py 
Reply all
Reply to author
Forward
0 new messages