Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

.

  • Loading branch information...
commit b5cd45a8e5f25299e719fe65e229cd8c41528111 1 parent 39f53c2
@floere authored
Showing with 44 additions and 48 deletions.
  1. +44 −48 server/test_project/app.rb
View
92 server/test_project/app.rb
@@ -19,56 +19,52 @@
class BookSearch < Sinatra::Application
- def self.routes
- weights = {
- [:author] => +6,
- [:title, :author] => +5,
- [:author, :year] => +2
- }
+ weights = {
+ [:author] => +6,
+ [:title, :author] => +5,
+ [:author, :year] => +2
+ }
- {
- books: Picky::Search.new(BooksIndex, ISBNIndex) {
- boost weights
- },
- books_ignoring: Picky::Search.new(BooksIndex, ISBNIndex) {
- boost weights
- ignore_unassigned_tokens true
- },
- book_each: Picky::Search.new(BookEachIndex) {
- boost weights
- # ignore :title
- },
- redis: Picky::Search.new(RedisIndex) {
- boost weights
- },
- memory_changing: Picky::Search.new(MemoryChangingIndex),
- redis_changing: Picky::Search.new(RedisChangingIndex),
- csv: Picky::Search.new(CSVTestIndex) {
- boost weights
- },
- isbn: Picky::Search.new(ISBNIndex),
- sym: Picky::Search.new(SymKeysIndex),
- geo: Picky::Search.new(RealGeoIndex),
- simple_geo: Picky::Search.new(MgeoIndex),
- iphone: Picky::Search.new(IphoneLocations),
- indexing: Picky::Search.new(IndexingIndex),
- file: Picky::Search.new(FileIndex),
- japanese: Picky::Search.new(JapaneseIndex) {
- searching removes_characters: /[^\p{Han}\p{Katakana}\p{Hiragana}\"\~\*\:\,]/i, # a-zA-Z0-9\s\/\-\_\&\.
- stopwords: /\b(and|the|of|it|in|for)\b/i,
- splits_text_on: /[\s\/\-\&]+/
- },
- nonstring: Picky::Search.new(NonstringDataIndex),
- partial: Picky::Search.new(PartialIndex),
- # sqlite: Picky::Search.new(SQLiteIndex), # TODO Fix, reinstate.
- commas: Picky::Search.new(CommaIdsIndex),
- all: Picky::Search.new(BooksIndex, CSVTestIndex, ISBNIndex, MgeoIndex) {
- boost weights
- }
+ {
+ books: Picky::Search.new(BooksIndex, ISBNIndex) {
+ boost weights
+ },
+ books_ignoring: Picky::Search.new(BooksIndex, ISBNIndex) {
+ boost weights
+ ignore_unassigned_tokens true
+ },
+ book_each: Picky::Search.new(BookEachIndex) {
+ boost weights
+ # ignore :title
+ },
+ redis: Picky::Search.new(RedisIndex) {
+ boost weights
+ },
+ memory_changing: Picky::Search.new(MemoryChangingIndex),
+ redis_changing: Picky::Search.new(RedisChangingIndex),
+ csv: Picky::Search.new(CSVTestIndex) {
+ boost weights
+ },
+ isbn: Picky::Search.new(ISBNIndex),
+ sym: Picky::Search.new(SymKeysIndex),
+ geo: Picky::Search.new(RealGeoIndex),
+ simple_geo: Picky::Search.new(MgeoIndex),
+ iphone: Picky::Search.new(IphoneLocations),
+ indexing: Picky::Search.new(IndexingIndex),
+ file: Picky::Search.new(FileIndex),
+ japanese: Picky::Search.new(JapaneseIndex) {
+ searching removes_characters: /[^\p{Han}\p{Katakana}\p{Hiragana}\"\~\*\:\,]/i, # a-zA-Z0-9\s\/\-\_\&\.
+ stopwords: /\b(and|the|of|it|in|for)\b/i,
+ splits_text_on: /[\s\/\-\&]+/
+ },
+ nonstring: Picky::Search.new(NonstringDataIndex),
+ partial: Picky::Search.new(PartialIndex),
+ # sqlite: Picky::Search.new(SQLiteIndex), # TODO Fix, reinstate.
+ commas: Picky::Search.new(CommaIdsIndex),
+ all: Picky::Search.new(BooksIndex, CSVTestIndex, ISBNIndex, MgeoIndex) {
+ boost weights
}
- end
-
- routes.each do |(path, things)|
+ }.each do |(path, things)|
get %r{\A/#{path}\z} do
things.search(params[:query], params[:ids] || 20, params[:offset] || 0).to_json
end
Please sign in to comment.
Something went wrong with that request. Please try again.