Class: GdsApi::Rummager
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#add_document(type, id, document) ⇒ Object
Add a document.
-
#advanced_search(args) ⇒ Object
deprecated
Deprecated.
Only in use by Whitehall. Use the ‘unified_search` method.
-
#delete_content!(base_path) ⇒ Object
Deletes a content-document from the index.
-
#delete_document(type, id) ⇒ Object
deprecated
Deprecated.
Use ‘delete_content!`
-
#get_content!(base_path) ⇒ Object
Retrieves a content-document from the index.
-
#unified_search(args) ⇒ Object
Unified search.
Methods inherited from Base
#client, #create_client, #get_list!, #initialize, #url_for_slug
Constructor Details
This class inherits a constructor from GdsApi::Base
Instance Method Details
#add_document(type, id, document) ⇒ Object
Add a document
Adds a document to the index
33 34 35 36 37 38 39 40 41 |
# File 'lib/gds_api/rummager.rb', line 33 def add_document(type, id, document) post_json!( documents_url, document.merge( _type: type, _id: id, ) ) end |
#advanced_search(args) ⇒ Object
Only in use by Whitehall. Use the ‘unified_search` method.
Advanced search
22 23 24 25 26 |
# File 'lib/gds_api/rummager.rb', line 22 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 |
#delete_content!(base_path) ⇒ Object
Deletes a content-document from the index. Content documents are pages on GOV.UK returned by search index. They don’t include best bets and other “meta” documents that are stored in Rummager.
49 50 51 52 |
# File 'lib/gds_api/rummager.rb', line 49 def delete_content!(base_path) request_url = "#{base_url}/content?link=#{base_path}" delete_json!(request_url) end |
#delete_document(type, id) ⇒ Object
Use ‘delete_content!`
delete_document(type, id) (DEPRECATED)
Delete any document from the search index. Unlike ‘delete_content!` this needs a type, but can be used to delete non-content documents from the index.
71 72 73 74 75 76 |
# File 'lib/gds_api/rummager.rb', line 71 def delete_document(type, id) delete_json!( "#{documents_url}/#{id}", _type: type, ) end |
#get_content!(base_path) ⇒ Object
Retrieves a content-document from the index. Content documents are pages on GOV.UK returned by search index.
59 60 61 62 |
# File 'lib/gds_api/rummager.rb', line 59 def get_content!(base_path) request_url = "#{base_url}/content?link=#{base_path}" get_json!(request_url) end |
#unified_search(args) ⇒ Object
Unified search
Perform a search
14 15 16 17 |
# File 'lib/gds_api/rummager.rb', line 14 def unified_search(args) request_url = "#{base_url}/unified_search.json?#{Rack::Utils.build_nested_query(args)}" get_json!(request_url) end |