Module: Khoj::Index

Included in:
Client, Function
Defined in:
lib/khoj/index.rb

Instance Method Summary collapse

Instance Method Details

#create_indexObject



4
5
6
7
# File 'lib/khoj/index.rb', line 4

def create_index
  response = @conn.put("/#{_index}")
  response.code == 200 ? true : (raise KhojException.new(response.parsed_response))
end

#delete_indexObject



9
10
11
12
# File 'lib/khoj/index.rb', line 9

def delete_index
  response = @conn.delete("/#{_index}")
  response.code == 200 ? true : (raise KhojException.new(response.parsed_response))
end

#index?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/khoj/index.rb', line 14

def index?
  @conn.head("/#{_index}").code == 200 ? true : false 
end

#index_statsObject



18
19
20
21
22
23
24
25
# File 'lib/khoj/index.rb', line 18

def index_stats
  response = @conn.get("/#{_index }/_stats")
  if response.code == 200
    response.parsed_response['_all']['total']['docs']['count']
  else
    raise KhojException.new(response.parsed_response) 
  end
end