Faceted navigation using django haystack and solr


Published on

Started publishing some code here: https://github.com/Nagyman/django-faceted-search Lots to do to make it more generally useful as it was extracted from a larger project.

Published in: Technology
  • Ditto the two comments below. I am making progress with django-haystack-solr, but have a long way to go. I believe your presentation will be a big help, but I have a long way to go to get all the pieces working together. More code would certainly accelerate the process. Thanks for sharing what you already have. wjburris@gmail.com
    Are you sure you want to  Yes  No
    Your message goes here
  • Yes, please, I am working with facets and haystack, and I would really benefit from your code, as an example. Is this part of an open source project?
    Are you sure you want to  Yes  No
    Your message goes here
  • Great deck, Craig! Is your facet code published anywhere? I think a lot of people would find your classes and template tags useful, either directly or as an example to work from.
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • \n
  • * (size, price, brand, type, categories).\n* improving findability\n* like products (e.g computers) not unlike products (books & cars)\n\n
  • AirBnb, Zappos, ToysRUs\n
  • Browse vs Search\nLinks vs Forms\nOften little or “No Results”\nUnpredictable combinations\n
  • SQL - Don’t torture yourself; not made for search\n
  • * Lucene: boosting, boolean, wildcards, ranges, grouping, etc. But Haystack takes care of this, unless you need more advanced searching\n* avoid hitting your DB\n
  • starting schema provided with Haystack - django_ct, django_id important for differentiating content types\nexpected text field for full-text search\n
  • * filter, exclude, order_by, highlight\n
  • * Similar to django model definition. If fields mirror model exactly, no extra work required. Otherwise use\n
  • * SearchIndex, a la django model definitions. Denormalize your data here.\n* text field template\n* prepare fields for indexing\n\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Faceted navigation using django haystack and solr

    1. 1. Faceted Navigation with django-haystack and solrDjangoTO 2012-02-09Craig Nagy @nagyman
    2. 2. What is Faceted Navigation/Browsing?• Visible options for narrowing a set of items based on metadata; interactive query building• Important for e-commerce sites with a significant number of products; shared classifications/metadata• Browse vs Search, Links vs. Forms
    3. 3. Engines with Faceted Search• Commercial: Endeca, FAST Search Server (Microsoft, SharePoint)• Open Source: solr (backed by Apache Lucene), Whoosh, Sphinx (“multi- queries”)• SQL - COUNT, GROUP BY, JOINs, oh my
    4. 4. Solr• Full text, faceted, distributed, amazing performance (Java)• Lucene syntax - title:”The Right Way” AND text:go, text:swim?ing, test~, craig nagy^4• JSON/XML API - transparent with Haystack• Run in a servlet container (e.g. Tomcat); Haystack provides easy local testing (Jetty) - manage.py solr --start• Data is denormalized; documents based on a schema
    5. 5. Solr Schema • All fields to index in schema.xml. Haystack has tools to help generate this file (manage.py build_solr_schema)• _exact fields for facets, multiValued=”true” for lists of data, data types
    6. 6. Haystack• Provides QuerySet-like API to a number of search backends haystack.query.SearchQuerySet • sqs = SearchQuerySet().filter(content=foo, pub_date__lte=datetime.date(2012, 1, 1))• Mirror your models, and any value you want to index• Automatic content_type handling• Performance Tip: Don’t access unindexed data
    7. 7. Haystack - Indexing• subclass haystack.indexes.SearchIndex.• prepare_<fieldname> or prepare callbacks• manage.py update_index or real-time
    8. 8. Full text indexingPrepare FieldsRegister
    9. 9. Not Included• Not included in Haystack • Views, templates, utilities, generating URLs, handling special data types• Custom Helpers: Searcher, FacetList, Facet, FacetItem, templatetags• Extras: Facet Landing Pages (e.g. Etsy, Zappos, G Adventures)
    10. 10. Facet Parsing• Haystack returns dictionaries of facet data; we parse into custom objects
    11. 11. Template Tagstemplatetags for arranging the faceted navigation
    12. 12. UI Pattern - Integrated Faceted Breadcrumbs (IFB)• http://boxesandarrows.com/view/faceted-finding-with (by Greg Nudelman)
    13. 13. Integrated Faceted Breadcrumbs
    14. 14. Refs• http://www.flickr.com/photos/morville/collections/72157603789246885/• http://haystacksearch.org/• https://github.com/toastdriven/django-haystack• http://boxesandarrows.com/view/faceted-finding-with• http://lucene.apache.org/solr/• http://django-haystack.readthedocs.org/en/latest/tutorial.html• http://www.gadventures.com/trips/
    15. 15. Fin.