Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Facet Searching using Ultrasphinx


Published on

Published in: Technology, Education
  • I have done a couple of papers through ⇒⇒⇒ ⇐⇐⇐ they have always been great! They are always in touch with you to let you know the status of paper and always meet the deadline!
    Are you sure you want to  Yes  No
    Your message goes here
  • I like this service ⇒ ⇐ from Academic Writers. I don't have enough time write it by myself.
    Are you sure you want to  Yes  No
    Your message goes here

Facet Searching using Ultrasphinx

  1. 1. <ul><li>Faceted browsing </li></ul><ul><li>using </li></ul><ul><li>UltraSphinx </li></ul>
  2. 2. About me <ul><li>A passionate rails developer </li></ul><ul><li>Author of </li></ul><ul><ul><li>Rails plugin State Select </li></ul></ul><ul><ul><li>Bash and ruby utility scripts </li></ul></ul><ul><li>Work with Vinsol </li></ul><ul><li>Blog: </li></ul>
  3. 3. Traditional Search Tools <ul><li>Designed to retrieve information </li></ul><ul><li>Situations in which the user knows exactly what he wants </li></ul><ul><li>Perform quite badly in most real situations </li></ul><ul><ul><li>Buying a digital camera </li></ul></ul><ul><ul><li>Finding a Job </li></ul></ul><ul><ul><li>Selecting a photo </li></ul></ul><ul><ul><li>Finding a restaurant </li></ul></ul>
  4. 4. Facets? <ul><li>Attributes of an Object in various categories </li></ul><ul><li>Examples: </li></ul><ul><ul><li>Music catalog: songs have attributes such as album, artist, title, length, date... </li></ul></ul><ul><ul><li>Recipes: cuisine, main ingredients, cooking style... </li></ul></ul><ul><ul><li>Content Site: articles have authors, dates, category, tags... </li></ul></ul><ul><ul><li>Image collection: artist, date, style, type of image, major colors, theme... </li></ul></ul>
  5. 5. Faceted Search <ul><li>Drilling down search results using dynamic taxonomies called Facets </li></ul>
  6. 6. Faceted Search <ul><li>Includes exposing the facets in dynamic taxonomies </li></ul><ul><li>Allows user </li></ul><ul><ul><li>To see exact options they have available to drill down the result </li></ul></ul><ul><ul><li>To switch easily between searching and browsing, using their own terminology for search </li></ul></ul>
  7. 7. Features Faceted Search <ul><li>Displaying various aspects of the current results set in multiple categorizations </li></ul><ul><li>Showing only populated categories, no dead-ends (links leading to empty lists) </li></ul><ul><ul><li>To see exactly the options they have available at that time </li></ul></ul><ul><ul><li>Displaying a count of the contents of each category </li></ul></ul>
  8. 8. When we need Faceted Search? <ul><li>User need to filter content using multiple taxonomy terms </li></ul><ul><li>User want to combine text searches, taxonomy term filtering, and other search criteria </li></ul><ul><li>User don't know precisely what they can find on your site, or what to search for </li></ul><ul><li>Users often get empty result sets when searching your site </li></ul><ul><li>Site has too much content for it to be displayed through fixed navigational structures </li></ul><ul><li>&quot;advanced&quot; search forms are not fun to use </li></ul>
  9. 9. Quick look at Ultrasphinx features <ul><li>Searching and ranking across multiple models </li></ul><ul><li>Delta index support </li></ul><ul><li>Excerpt highlighting </li></ul><ul><li>Google-style query parser </li></ul><ul><li>Spellcheck </li></ul><ul><li>Faceting on text, date, and numeric fields </li></ul><ul><li>Field weighting, merging, and aliasing </li></ul><ul><li>Belongs_to and has_many includes </li></ul><ul><li>Drop-in compatibility with will_paginate </li></ul>
  10. 10. Indexing Data <ul><li>Article Model </li></ul><ul><li>is_indexed :fields => [ </li></ul><ul><ul><ul><ul><ul><ul><ul><li>'created_at', </li></ul></ul></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><ul><ul><li>'title', </li></ul></ul></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><ul><ul><li>{:field => 'body', :as => 'description'}, </li></ul></ul></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><ul><ul><li>{:field => 'category', :facet => true, :as => 'category_name' } </li></ul></ul></ul></ul></ul></ul></ul><ul><li> ], </li></ul><ul><li>:conditions => &quot;status = 'published' &quot;, </li></ul><ul><li>:include => [{:association_name => 'Author', :field => 'name', :as => 'author_name'}] </li></ul>
  11. 11. Preparing index withUltrasphinx <ul><li>rake ultrasphinx:configure </li></ul><ul><li>rake ultrasphinx:index </li></ul><ul><li>rake ultrasphinx:daemon:start </li></ul>
  12. 12. Running Queries <ul><li>@search = => @query, :class_names => 'Article', :per_page => 20) </li></ul><ul><li> </li></ul><ul><li>@search.results </li></ul>
  13. 13. Lets do it practically
  14. 14. Use Case <ul><li>We have a Product model and we want to implement search on its various fields. Also we want to use its brand, category and celebration* as facets. </li></ul>* Occassion when a product can be used
  15. 15. Product Model <ul><li>is_indexed :fields => [ :description, :name, </li></ul><ul><li>{:field => :celebration, :facet => true} </li></ul><ul><li>], </li></ul><ul><li>:include => [ </li></ul><ul><li>{ :association_name => 'brand', :field => 'name', :facet=>true, :as => 'brand', </li></ul><ul><li>:association_sql => &quot;left outer join brands brand on products.brand_id = </li></ul><ul><li>; </li></ul><ul><li>}, </li></ul><ul><li>{ :class_name => &quot;Category&quot;, :field => 'title', :facet=>true, :as => 'category', </li></ul><ul><ul><li>:association_sql => &quot;left outer join categories on = </li></ul></ul><ul><ul><li>products.category_id&quot;} </li></ul></ul><ul><li>] </li></ul>
  16. 16. Prepare index and start search daemon <ul><li>rake ultrasphinx:configure </li></ul><ul><li>rake ultrasphinx:index </li></ul><ul><li>rake ultrasphinx:daemon:start </li></ul><ul><li>* remember to restart app server </li></ul>
  17. 17. Search Controller <ul><li>@query = params[:query] || “”' </li></ul><ul><li>@filters = params[:filters] || '”” </li></ul><ul><li>@page = params[:page] || 1 </li></ul><ul><li>@search = => @query+&quot; &quot;+@filters, :facets => [&quot;category&quot;, &quot;brand&quot;, &quot;celebration&quot;], :page => @page, :class_names => 'Product') </li></ul><ul><li> </li></ul><ul><li>@products = @search.results </li></ul>
  18. 18. View
  19. 19. Output
  20. 20. References <ul><li>UltraSphinx </li></ul><ul><ul><li> </li></ul></ul><ul><li>Sphinx </li></ul><ul><ul><li> </li></ul></ul>
  21. 21. <ul><li>Thanks a lot </li></ul><ul><li>:-) </li></ul>