Class: Geoloader::Services::Solr
- Inherits:
-
Object
- Object
- Geoloader::Services::Solr
- Defined in:
- lib/geoloader/services/solr.rb
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
-
#create_document(asset) ⇒ Object
Add a new document to the index.
-
#delete_by_workspace(workspace) ⇒ Object
Delete all documents in a workspace.
-
#get_workspace_counts ⇒ Object
Count the number of documents in each workspace.
-
#initialize ⇒ Solr
constructor
Initialize the API wrapper.
Constructor Details
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
9 10 11 |
# File 'lib/geoloader/services/solr.rb', line 9 def resource @resource end |
Instance Method Details
#create_document(asset) ⇒ Object
Add a new document to the index.
23 24 25 26 |
# File 'lib/geoloader/services/solr.rb', line 23 def create_document(asset) @resource.add(asset.solr_document) @resource.commit end |
#delete_by_workspace(workspace) ⇒ Object
Delete all documents in a workspace.
54 55 56 57 |
# File 'lib/geoloader/services/solr.rb', line 54 def delete_by_workspace(workspace) @resource.delete_by_query("WorkspaceName:#{workspace}") @resource.commit end |
#get_workspace_counts ⇒ Object
Count the number of documents in each workspace.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/geoloader/services/solr.rb', line 31 def get_workspace_counts workspaces = [] # Select all documents, 0 rows, faceting on workspace. query = { :queries => "*:*", :facets => { :fields => "WorkspaceName" }, :rows => 0 } # Flatted out the counts. @resource.find(query).facets.each do |facet| facet.items.each do |item| workspaces << [item.value, item.hits] end end workspaces end |