Ok, I think I figured it out.
In the solr backend's SearchQuery.build_query_fragment there's a
couple of lines of code that look like this:
# Check to see if it's a phrase for an exact match.
if ' ' in value:
value = '"%s"' % value
By changing the if statement just a hair (slight hack, the "right" way
would be to check for beginning and end braces) everything works
peachy.
# Check to see if it's a phrase for an exact match.
if ' ' in value and not '{' in value:
value = '"%s"' % value
So I just created a subclass of the solr backend, which I cleverly
called geosolr, which has a new build_query_fragment method. I'll
hand my final solution over to the authors so they can integrate it
into the solr backend if they so choose.
JoeK
On Dec 11, 8:42 am, Joe Kueser <
joe.kue...@gmail.com> wrote:
> Well, a couple of more things I've noticed.
>
> The problem seems to be centered around that, somewhere along the line, Haystack (or the Solr backend) is seeing a query with spaces in it and is putting the query in quotes. This is the correct thing to happen 99% of the time, I'm sure, just not in my case :-)
>
> So I tried being clever and replace the spaces with %20's. Can you guess what happened? The %20 was replaced with %2520. So then I tried + signs. No go there, either, though in both cases, the query was not quoted.
>
> So I need to track down where the quotes are being injected. Shouldn't be too hard. Probably code somewhere that looks like:
>
> '"%s"' % query
>
> I'll post a solution if I find one.
>
> In the mean time, if anyone has any ideas, they are still very welcome :-)
>
> Thanks.
>
> Joe K
>
> On Dec 10, 2009, at 10:19 PM, Daniel Lindsley wrote:
>
>
>
> > JoeK,
>
> > Interesting. I still have getting around to testing SpatialSolr on
> > my TODO list. Since I don't have a working environment, here's what I
> > think might work:
>
> > sqs = SearchQuerySet().filter(content='dog')
> > sqs = sqs.raw_query('{!spatial lat=37.0842271 long=-94.513281
> > radius=25 unit=miles
> >> calc=arc threadCount=2}')
>
> > I believe that ought to pass all of the SpatialSolr bits to the
> > backend untouched and IIRC do the right thing with the 'dog' part of
> > the query as well. If not, I think there are other options but I'm
> > hoping that will work for you.
>
> > Daniel
>
> >> For more options, visit this group athttp://
groups.google.com/group/django-haystack?hl=en.