class GdsApi::Rummager
@api documented
def add_document(type, id, document)
- See: https://github.com/alphagov/rummager/blob/master/docs/documents.md -
Returns:
-
(GdsApi::Response)- A status code of 202 indicates the document has been successfully queued.
Parameters:
-
document(Hash) -- The document to add. Must match the rummager schema matchin the `type` parameter and contain a `link` field. -
id(String) -- The rummager/elasticsearch id. Typically the same as the `link` field, but this is not strictly enforced. -
type(String) -- The rummager/elasticsearch document type.
def add_document(type, id, document) post_json( documents_url, document.merge( _type: type, _id: id, ) ) end
def advanced_search(args)
- Only in use by Whitehall. Use the `#search` method.
def advanced_search(args) raise ArgumentError.new("Args cannot be blank") if args.nil? || args.empty? request_path = "#{base_url}/advanced_search?#{Rack::Utils.build_nested_query(args)}" get_json(request_path) end
def base_url
def base_url endpoint end
def delete_content(base_path)
- See: https://github.com/alphagov/rummager/blob/master/docs/content-api.md -
Parameters:
-
base_path() -- Base path of the page on GOV.UK.
def delete_content(base_path) request_url = "#{base_url}/content?link=#{base_path}" delete_json(request_url) end
def delete_content!(*)
- Private: -
def delete_content!(*) raise "`Rummager#delete_content!` is deprecated. Use `Rummager#delete_content`" end
def delete_document(type, id)
-
id(String) -- The rummager/elasticsearch id. Typically the same as the `link` field. -
type(String) -- The rummager/elasticsearch document type.
def delete_document(type, id) delete_json( "#{documents_url}/#{id}", _type: type, ) end
def documents_url
def documents_url "#{base_url}/documents" end
def get_content(base_path)
- See: https://github.com/alphagov/rummager/blob/master/docs/content-api.md -
Parameters:
-
base_path(String) -- Base path of the page on GOV.UK.
def get_content(base_path) request_url = "#{base_url}/content?link=#{base_path}" get_json(request_url) end
def get_content!(*)
- Private: -
def get_content!(*) raise "`Rummager#get_content!` is deprecated. Use `Rummager#get_content`" end
def search(args)
- See: https://github.com/alphagov/rummager/blob/master/docs/search-api.md -
Parameters:
-
args(Hash) -- A valid search query. See Rummager documentation for options.
def search(args) request_url = "#{base_url}/search.json?#{Rack::Utils.build_nested_query(args)}" get_json(request_url) end