Class: RediSearcher::Document

Inherits:
Client::CommandBase show all
Defined in:
lib/redi_searcher/document.rb

Constant Summary collapse

OPTIONS_FLAGS =
{
  add: [:nosave, :replace, :partial],
  del: [:dd]
}
OPTIONS_PARAMS =
{
  add: [:language, :payload],
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index, doc_id, weight = nil, **fields) ⇒ Document

Returns a new instance of Document.



14
15
16
17
18
19
# File 'lib/redi_searcher/document.rb', line 14

def initialize(index, doc_id, weight = nil, **fields)
  @index = index
  @doc_id = doc_id
  @fields = filter_by_schema(fields)
  @weight = weight || RediSearcher::DEFAULT_WEIGHT
end

Instance Attribute Details

#doc_idObject (readonly)

Returns the value of attribute doc_id.



12
13
14
# File 'lib/redi_searcher/document.rb', line 12

def doc_id
  @doc_id
end

#fieldsObject (readonly)

Returns the value of attribute fields.



12
13
14
# File 'lib/redi_searcher/document.rb', line 12

def fields
  @fields
end

#indexObject (readonly)

Returns the value of attribute index.



12
13
14
# File 'lib/redi_searcher/document.rb', line 12

def index
  @index
end

#weightObject (readonly)

Returns the value of attribute weight.



12
13
14
# File 'lib/redi_searcher/document.rb', line 12

def weight
  @weight
end

Instance Method Details

#add(**options) ⇒ Object



21
22
23
# File 'lib/redi_searcher/document.rb', line 21

def add(**options)
  index.client.call(ft_add(options))
end

#del(**options) ⇒ Object



25
26
27
# File 'lib/redi_searcher/document.rb', line 25

def del(**options)
  index.client.call(ft_del(options))
end