Class: CDMBL::DefaultSolr

Inherits:
Object
  • Object
show all
Defined in:
lib/cdmbl/default_solr.rb

Overview

Commnicate with Solr: add / delete stuff

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url: 'http://localhost:8983/solr/core-here', client: RSolr) ⇒ DefaultSolr

Returns a new instance of DefaultSolr.



7
8
9
10
# File 'lib/cdmbl/default_solr.rb', line 7

def initialize(url: 'http://localhost:8983/solr/core-here', client: RSolr)
  @url    = url
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



6
7
8
# File 'lib/cdmbl/default_solr.rb', line 6

def client
  @client
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/cdmbl/default_solr.rb', line 6

def url
  @url
end

Instance Method Details

#add(records) ⇒ Object



27
28
29
# File 'lib/cdmbl/default_solr.rb', line 27

def add(records)
  connection.add records
end

#connectionObject



23
24
25
# File 'lib/cdmbl/default_solr.rb', line 23

def connection
  @connection ||= client.connect url: url
end

#delete(ids) ⇒ Object



31
32
33
# File 'lib/cdmbl/default_solr.rb', line 31

def delete(ids)
  connection.delete_by_id ids
end

#ids(start: 0) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/cdmbl/default_solr.rb', line 12

def ids(start: 0)
  connection.get('select',
    :params => { :q => '*:*',
      :defType => 'edismax',
      :fl => '',
      :rows => 10,
      :start => start
    }
  )
end