Method: Wgit::DSL#search
- Defined in:
- lib/wgit/dsl.rb
#search(query, stream: $stdout, top_result_only: true, include_score: false, case_sensitive: false, whole_sentence: true, limit: 10, skip: 0, sentence_limit: 80) {|doc| ... } ⇒ Array<Wgit::Document>
Performs a search of the database's indexed documents and pretty prints
the results in a search engine-esque format. See
Wgit::Database::DatabaseAdapter#search and Wgit::Document#search!
for details of how the search methods work.
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/wgit/dsl.rb', line 268 def search( query, stream: $stdout, top_result_only: true, include_score: false, case_sensitive: false, whole_sentence: true, limit: 10, skip: 0, sentence_limit: 80 ) stream ||= File.open(File::NULL, 'w') results = get_db.search( query, case_sensitive:, whole_sentence:, limit:, skip:) results.each do |doc| doc.search_text!( query, case_sensitive:, whole_sentence:, sentence_limit:) yield(doc) if block_given? end if top_result_only Wgit::Utils.pprint_top_search_results(results, include_score:, stream:) else Wgit::Utils.pprint_all_search_results(results, include_score:, stream:) end results end |