Class: SearchKit::Search::CLI
- Inherits:
-
Thor
- Object
- Thor
- SearchKit::Search::CLI
- Includes:
- Messaging
- Defined in:
- lib/search_kit/search/cli.rb,
lib/search_kit/search/cli/actions.rb
Defined Under Namespace
Modules: Actions
Instance Method Summary collapse
Methods included from Messaging
Instance Method Details
#search(slug, phrase) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/search_kit/search/cli.rb', line 15 def search(slug, phrase) search = Actions::Search.perform( client: client, phrase: phrase, slug: slug ) info "Searching `#{slug}` for titles matching `#{phrase}`:" info " - Found #{search.results} titles in #{search.time}ms" display = .fetch('display', []) search.documents.each do |document| if display.any? fields = display.map { |field| document.get(field) } info " -- #{fields.join(' | ')} | score: #{document.score}" else info " -- #{document.id} | score: #{document.score}" end end end |