can haystack do this?

36 views
Skip to first unread message

ab

unread,
Apr 29, 2009, 12:53:27 PM4/29/09
to django-haystack
Hi,

Just wondering if I already have a legacy Solr index (created by a
separate java application) can I still use django-haystack for
searching? or I must create the index using django-haystack?

Regards
ab

ab

unread,
May 1, 2009, 2:57:15 AM5/1/09
to django-haystack
Found my answer ...

-----
Non-Model-based data. If you just want to index random data (flat
files, alternate sources, etc.), Haystack isn’t a good solution.
Haystack is very Model-based and doesn’t work well outside of that use
case.
-----

Solr also do this out of the box i.e. index database too.

http://wiki.apache.org/solr/DataImportHandler

Daniel Lindsley

unread,
May 1, 2009, 3:40:57 AM5/1/09
to django-...@googlegroups.com
ab,


Sorry Haystack isn't what you're looking for. You might benefit
from using pysolr (https://github.com/toastdriven/pysolr/), which is a
Python interface to Solr. It's much lower level than Haystack but will
let you use your existing index from Python.


Daniel

srini

unread,
May 6, 2009, 7:05:51 AM5/6/09
to django-haystack
Hi, Daniel

Is it possible to use wildcards in haystack..............

If possible, can you tell me the way to use wildcards in
haystack

Thank You,

Daniel Lindsley

unread,
May 6, 2009, 9:30:01 AM5/6/09
to django-...@googlegroups.com
Srini,


Praveen is asking for the same thing. It's possible with at least
two of the backends (Solr & Whoosh) but I need to check the remaining
engines to see if there is support for wildcards. If so, I'll add a
new filter type to Haystack to do 'icontains' lookups. So for now, no,
but I'll have a better answer in a couple days.


Daniel

srini

unread,
May 13, 2009, 8:54:15 AM5/13/09
to django-haystack
Hi, Daniel

well haystack is working similar to wildcard,
just we did the following modification in
whoosh_backend.py,

ie, in line 28 in RESERVED_CHARACTERS we removed " * "
from it and we are concatinating that * to the keyword for which
we are searching and it's working fine...

Thank you Daniel for your help,
thank you so much, you have done such a good job inventing haystack.

srini

unread,
May 13, 2009, 8:59:54 AM5/13/09
to django-haystack
Hi, all

These are the changes we have done in
whoosh_backend.py, and forms.py


In whoosh_backend.py, line 28 we removed "*"

RESERVED_CHARACTERS = (
'\\', '+', '-', '&&', '||', '!', '(', ')', '{', '}',
'[', ']', '^', '"', '~', '?', ':',
)

in forms.py in SearchForm line 31 in search
we added ---------------> qry = "*" + qry + "*"

class SearchForm(forms.Form):
q = forms.CharField(required=False)

def __init__(self, *args, **kwargs):
self.searchqueryset = kwargs.get('searchqueryset', None)

if self.searchqueryset is None:
self.searchqueryset = SearchQuerySet()

try:
del(kwargs['searchqueryset'])
except KeyError:
pass

super(SearchForm, self).__init__(*args, **kwargs)

def search(self):
self.clean()
qry = self.cleaned_data['q']
qry = qry.lower()
qry = "*" + qry + "*"
return self.searchqueryset.auto_query(qry)

Thank you

Daniel Lindsley

unread,
May 13, 2009, 10:31:25 AM5/13/09
to django-...@googlegroups.com
srini,


I view that as potentially dangerous, given that you're exposing
wildcard support (which can be expensive) raw to users. I'm
comfortable given that capability to developers (see issue #24) but
that's kinda scary to hand over to the end user. As for prior art
here, it doesn't look like Google or Yahoo expose this to users
either.

http://www.google.com/search?hl=en&q=hayst*&btnG=Google+Search&aq=f&oq=
http://search.yahoo.com/search;_ylt=A0geu5rU2ApKhX8AULdXNyoA?p=hayst*&y=Search&fr=yfp-t-501&fr2=sb-top&sao=1

If you really want your users to be able to do that, that would be
your call. You don't (or shouldn't as that would be a bug) need to
remove the '*' from RESERVED_CHARACTERS, as that's used in the
'SearchQuery.clean' method only. Otherwise, the way you overrode the
form is fine, if you're comfortable with that.


Daniel

Praveen

unread,
May 14, 2009, 9:37:20 AM5/14/09
to django-haystack
Hi Daniel,
toastdriven add this issue based on my request and thanks for
implementing this feature in future.
Thanks

On May 13, 7:31 pm, Daniel Lindsley <polarc...@gmail.com> wrote:
> srini,
>
>    I view that as potentially dangerous, given that you're exposing
> wildcard support (which can be expensive) raw to users. I'm
> comfortable given that capability to developers (see issue #24) but
> that's kinda scary to hand over to the end user. As for prior art
> here, it doesn't look like Google or Yahoo expose this to users
> either.
>
> http://www.google.com/search?hl=en&q=hayst*&btnG=Google+Search&aq=f&oq=http://search.yahoo.com/search;_ylt=A0geu5rU2ApKhX8AULdXNyoA?p=hayst*...
>
>    If you really want your users to be able to do that, that would be
> your call. You don't (or shouldn't as that would be a bug) need to
> remove the '*' from RESERVED_CHARACTERS, as that's used in the
> 'SearchQuery.clean' method only. Otherwise, the way you overrode the
> form is fine, if you're comfortable with that.
>
> Daniel
>
Reply all
Reply to author
Forward
0 new messages