Added support for couchdb-lucene.

Added a search method to CouchRest:Database to search the documents in a
given database.  Added support for a :search parameter to Collection's
paginated_each method, which will allow you to paginate over a set of
search results.

This code has been brought to you by Dave Farkas (sakrafd) and
Arnaud Berthomier (oz).
This commit is contained in:
John Wood 2010-03-11 11:17:15 -06:00 committed by Will Leinweber
parent 13d76d38de
commit b26f90d2ff
5 changed files with 115 additions and 9 deletions

View file

@ -816,5 +816,25 @@ describe CouchRest::Database do
end
describe "searching a database" do
before(:each) do
search_function = { 'defaults' => {'store' => 'no', 'index' => 'analyzed_no_norms'},
'index' => "function(doc) { ret = new Document(); ret.add(doc['name'], {'field':'name'}); ret.add(doc['age'], {'field':'age'}); return ret; }" }
@db.save_doc({'_id' => '_design/search', 'fulltext' => {'people' => search_function}})
@db.save_doc({'_id' => 'john', 'name' => 'John', 'age' => '31'})
@db.save_doc({'_id' => 'jack', 'name' => 'Jack', 'age' => '32'})
@db.save_doc({'_id' => 'dave', 'name' => 'Dave', 'age' => '33'})
end
it "should be able to search a database using couchdb-lucene" do
if couchdb_lucene_available?
result = @db.search('search/people', :q => 'name:J*')
doc_ids = result['rows'].collect{ |row| row['id'] }
doc_ids.size.should == 2
doc_ids.should include('john')
doc_ids.should include('jack')
end
end
end
end