Class: IODIndex

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, flavor = "standard", type = "normal", client: nil) ⇒ IODIndex

Returns a new instance of IODIndex.



281
282
283
284
285
286
# File 'lib/iodruby.rb', line 281

def initialize(name,flavor="standard",type="normal",client:nil)
  @name=name

  @client=client
  @docs=[]
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



277
278
279
# File 'lib/iodruby.rb', line 277

def client
  @client
end

#nameObject (readonly)

Returns the value of attribute name.



278
279
280
# File 'lib/iodruby.rb', line 278

def name
  @name
end

Instance Method Details

#==(other_object) ⇒ Object



340
341
342
# File 'lib/iodruby.rb', line 340

def ==(other_object)
  comparison_object.equal?(self) || (comparison_object.instance_of?(self.class) && @name == other_object.name)
end

#addDoc(doc) ⇒ Object



316
317
318
319
320
321
322
323
# File 'lib/iodruby.rb', line 316

def addDoc(doc)
  docs=Hash.new

#		docs[:document]=[doc.data]
#		data={json:docs.to_json,index:@name}
#		@client.postasync("addtotextindex",data)
  puts @client.addDoc(doc,@name)
end

#addDocs(docs, async = false) ⇒ Object



326
327
328
329
330
331
332
333
# File 'lib/iodruby.rb', line 326

def addDocs(docs,async=false)

#		docs[:document]=[doc.data]
#		data={json:docs.to_json,index:@name}
#		@client.postasync("addtotextindex",data)

  return @client.addDocs(docs,@name,async)
end

#commit(async = false) ⇒ Object



304
305
306
307
308
309
310
311
312
313
314
# File 'lib/iodruby.rb', line 304

def commit(async=false)
#		docs={document:@docs}
#		data={json:docs.to_json,index:@name}
#		puts docs.to_json

  #[email protected]("addtotextindex",data)
  #@docs=[]
  response=addDocs(@docs,async)
  @docs=[]
  return response
end

#deleteObject



335
336
337
338
# File 'lib/iodruby.rb', line 335

def delete()
  clientcheck()
  @client.deleteIndex(self)
end

#pushDoc(doc) ⇒ Object



299
300
301
302
# File 'lib/iodruby.rb', line 299

def pushDoc(doc)
  @docs.push(doc)

end

#query(text, data = Hash.new) ⇒ Object



288
289
290
291
292
293
294
295
# File 'lib/iodruby.rb', line 288

def query(text,data=Hash.new)
  data[:database_match]=@name

  data[:text]=text
result=@client.post("querytextindex",data)
result["documents"].map!{|doc| IODDoc.new(doc) }
  return result
end

#sizeObject



296
297
298
# File 'lib/iodruby.rb', line 296

def size()
  return @docs.length
end