solr and sunspot

11
Solr and sunspot Learnings from RedBubble Paul Coia

Upload: paul-coia

Post on 30-Nov-2014

737 views

Category:

Technology


2 download

DESCRIPTION

A presentation I gave to Ruby on Rails Oceania in 2011 about our use of Solr and Sunspot at Redbubble

TRANSCRIPT

Page 1: Solr and sunspot

Solr and sunspotLearnings from RedBubblePaul Coia

Page 2: Solr and sunspot

Who am I?

What are Solr and sunspot?

Why do we use them?

Page 3: Solr and sunspot

What is Solr?Solr is Apache’s search engine

Wraps and enhances Lucene

Java webapp (Tomcat)

Page 4: Solr and sunspot

And sunspot ?sunspot: Gem for Solr communication

sunspot-rails: Plugin for Rails

Indexing DSL

Searching DSL

(Magic) Dynamic index schema for Solr

Development convenience scripts

Will_paginate integration

Page 5: Solr and sunspot

What attracted us to Solr?Facets

Incremental index updates

Scalability, master + slave(s)

Easy to add new fields (sunspot magic schema)

Do everything in Ruby

Communication between app and Solr (no DB)

Page 6: Solr and sunspot

DSL - Indexingclass Post < ActiveRecord::Base searchable do text :title text :body string :sort_title do title.downcase.sub(/^an?|the)\W+/, ‘’) end string :tags, :multiple => true do tags.split(",") unless tags.nil? end endend

Page 7: Solr and sunspot

DSL - Searching@search = Post.search(:include => :comments) do |s| s.fulltext params[:q], :fields => [:title, :body] s.facet :tags, :sort => :count s.order_by :sort_title, :ascend

@search.results.each do |result|

end

Page 8: Solr and sunspot

Facets

Page 9: Solr and sunspot

DSL - [email protected](:tags).rows.each do |tag_facet| tag_facet.value tag_facet.countend

Page 10: Solr and sunspot

Performance JVM memory

Cache sizes

Search warming

Auto Commit settings/Replication