开发者

How do you improve search?

开发者 https://www.devze.com 2023-03-22 23:54 出处:网络
I just got haystack with solr installed and created a custom view: from haystack.query im开发者_如何学Pythonport SearchQuerySet

I just got haystack with solr installed and created a custom view:

from haystack.query im开发者_如何学Pythonport SearchQuerySet
def post_search(request, template_name='search/search.html'):
    getdata = request.GET.copy()
    try:
        results = SearchQuerySet().filter(title=getdata['search'])[:10]
    except:
        results = None
    return render_to_response(template_name, locals(), context_instance=RequestContext(request))

This view only returns exact matches on the title field. How do I do at least things like the sql LIKE '%string%' (or at least i think it's this) where if I search 'i' or 'IN' or 'index' I will get the result 'index'?

Also are most of the ways you search edited using haystack or solr?

What other good practices/search improvements do you suggest (please give implementation too)?

Thanks a bunch in advance!


When you use Haystack/Solr, the idea is that you have to tell Haystack/Solr what you want indexed for a particular object. So say you wanted to build a find as you type index for a basic dictionary. If you wanted it to just match prefixes, for the word Boston, you'd need to tell it to index B, Bo, Bos, etc. and then you'd issue a query for whatever the current search expression was and you could return the results. If you wanted to search any part of the word, you'd need to build suffix trees and then Solr would take care of indexing them.

Look at templates in Haystack for more info. http://docs.haystacksearch.org/dev/best_practices.html#well-constructed-templates

The question you're asking is fairly generic, it might help to give specifics about what people are searching for. Then it'll be easier to suggest how to index the data. Good luck.

0

精彩评论

暂无评论...
验证码 换一张
取 消