lib/picky/application.rb in picky-1.4.1 vs lib/picky/application.rb in picky-1.4.2

- old
+ new

@@ -11,35 +11,37 @@ # The generator # $ picky generate unicorn_server project_name # will generate an example <tt>project_name/app/application.rb</tt> file for you # with some example code inside. # -# == index(name, source) +# == Index::Memory.new(name, source) # -# Next, define where your data comes from. You use the <tt>index</tt> method for that: -# my_index = index :some_index_name, some_source +# Next, define where your data comes from. You use the <tt>Index::Memory.new</tt> method for that: +# my_index = Index::Memory.new :some_index_name, some_source # You give the index a name (or identifier), and a source (see Sources), where its data comes from. Let's do that: # class MyGreatSearch < Application # -# books = index :books, Sources::CSV.new(:title, :author, :isbn, file:'app/library.csv') +# books = Index::Memory.new :books, Sources::CSV.new(:title, :author, :isbn, file:'app/library.csv') # # end # Now we have an index <tt>books</tt>. # # That on itself won't do much good. # -# == index.define_category(identifier, options = {}) +# Note that a Redis index is also available: Index::Redis.new. # +# == index_instance.define_category(identifier, options = {}) +# # Picky needs us to define categories on the data. # # Categories help your user find data. # It's best if you look at an example yourself: http://floere.github.com/picky/examples.html # # Let's go ahead and define a category: # class MyGreatSearch < Application # -# books = index :books, Sources::CSV.new(:title, :author, :isbn, file:'app/library.csv') +# books = Index::Memory.new :books, Sources::CSV.new(:title, :author, :isbn, file:'app/library.csv') # books.define_category :title # # end # Now we could already run the indexer: # $ rake index @@ -65,14 +67,12 @@ # class MyGreatSearch < Application # # books = index :books, Sources::CSV.new(:title, :author, :isbn, file:'app/library.csv') # books.define_category :title # -# full_books_query = Query::Full.new books +# route %r{^/books/full$} => Query::Full.new(books) # -# route %r{^/books/full$} => full_books_query -# # end # That's it! # # Now run the indexer and server: # $ rake index @@ -126,27 +126,24 @@ # splits_text_on: /[\s\/\-\,\&]+/, # removes_characters_after_splitting: /\./, # substitutes_characters_with: CharacterSubstituters::WestEuropean.new, # maximum_tokens: 4 # -# books = index :books, Sources::CSV.new(:title, :author, :isbn, file:'app/library.csv') +# books = Index::Memory.new :books, Sources::CSV.new(:title, :author, :isbn, file:'app/library.csv') # books.define_category :title, # qualifiers: [:t, :title, :titre], # partial: Partial::Substring.new(:from => 1), # similarity: Similarity::Phonetic.new(2) # books.define_category :author, # partial: Partial::Substring.new(:from => -2) # books.define_category :isbn # # query_options = { :weights => { [:title, :author] => +3, [:author, :title] => -1 } } # -# full_books_query = Query::Full.new books, query_options -# live_books_query = Query::Full.new books, query_options +# route %r{^/books/full$} => Query::Full.new(books, query_options) +# route %r{^/books/live$} => Query::Live.new(books, query_options) # -# route %r{^/books/full$} => full_books_query -# route %r{^/books/live$} => live_books_query -# # end # That's actually already a full-blown Picky App! # class Application @@ -157,18 +154,18 @@ # Returns a configured tokenizer that # is used for indexing by default. # def default_indexing options = {} - Tokenizers::Index.default = Tokenizers::Index.new(options) + Internals::Tokenizers::Index.default = Internals::Tokenizers::Index.new(options) end # Returns a configured tokenizer that # is used for querying by default. # def default_querying options = {} - Tokenizers::Query.default = Tokenizers::Query.new(options) + Internals::Tokenizers::Query.default = Internals::Tokenizers::Query.new(options) end # Create a new index for indexing and for querying. # # Parameters: @@ -179,12 +176,14 @@ # * source: The source the data comes from. See Sources::Base. # # Options: # * result_identifier: Use if you'd like a different identifier/name in the results JSON than the name of the index. # + # TODO Obsolete. Phase out. + # def index name, source, options = {} - IndexAPI.new name, source, options + Index::Memory.new name, source, options end # Routes. # delegate :route, :root, :to => :rack_adapter @@ -199,10 +198,10 @@ # def call env rack_adapter.call env end def rack_adapter # :nodoc: - @rack_adapter ||= FrontendAdapters::Rack.new + @rack_adapter ||= Internals::FrontendAdapters::Rack.new end # Finalize the subclass as soon as it # has finished loading. # \ No newline at end of file