Class: ChefAPI::Resource::PartialSearch
- Defined in:
- lib/chef-api/resources/partial_search.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.query(index, keys, query = '*:*', options = {}) ⇒ self
About search : docs.chef.io/chef_search.html.
Methods inherited from Base
#_attributes, #_prefix, all, #attribute?, build, classname, collection, collection_path, connection, count, create, delete, #destroy, destroy, destroy_all, #diff, #dirty?, each, #errors, exists?, expanded_collection_path, fetch, from_file, from_json, from_url, has_many, #id, #ignore_attribute?, #initialize, inspect, #inspect, list, #new_resource?, post, #primary_key, protect, #protected?, protected_resources, put, #reload!, resource_path, #resource_path, #save, #save!, schema, #to_hash, #to_json, to_s, #to_s, type, update, #update, #update_attribute, #valid?, #validate!, #validators
Constructor Details
This class inherits a constructor from ChefAPI::Resource::Base
Class Method Details
.query(index, keys, query = '*:*', options = {}) ⇒ self
About search : docs.chef.io/chef_search.html
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/chef-api/resources/partial_search.rb', line 27 def query(index, keys, query = '*:*', = {}) return nil if index.nil? params = {}.tap do |o| o[:q] = query o[:rows] = [:rows] || 1000 o[:sort] = [:sort] || 'X_CHEF_id_CHEF_X' o[:start] = [:start] || 0 end path = (index: index.to_s) response = connection.post(path, keys.to_json, params) response['rows'].map! { |row| row['data'] } from_json(response, index: index.to_s) end |