Skip to content

Commit

Permalink
Clean redundant type code and remove deprecated/non-existent APIs suc…
Browse files Browse the repository at this point in the history
…h as Warmer
  • Loading branch information
neilcook committed Oct 17, 2024
1 parent c857e4a commit 86c4979
Show file tree
Hide file tree
Showing 17 changed files with 6 additions and 734 deletions.
110 changes: 0 additions & 110 deletions src/elasticsearch/Indices.lua
Original file line number Diff line number Diff line change
Expand Up @@ -429,40 +429,6 @@ function Indices:putTemplate(params)
return self:requestEndpoint("PutTemplate", params)
end

-------------------------------------------------------------------------------
-- Exists Type function
--
-- @usage
-- params["index"] = (list) A comma-separated list of index names; use '_all' to check the types
-- across all indices (Required)
-- ["type"] = (list) A comma-separated list of document types to check (Required)
-- ["ignore_unavailable"] = (boolean) Whether specified concrete indices should be ignored when unavailable
-- (missing or closed)
-- ["allow_no_indices"] = (boolean) Whether to ignore if a wildcard indices expression resolves into no
-- concrete indices. (This includes '_all' string or when no indices have been specified)
-- ["expand_wildcards"] = (enum) Whether to expand wildcard expression to concrete indices that are open,
-- closed or both. (open,closed,none,all) (default: open)
-- ["local"] = (boolean) Return local information, do not retrieve the state from master node
-- (default: false)
--
-- @param params The put template Parameters
--
-- @return table Error or the data received from the elasticsearch server
-------------------------------------------------------------------------------
function Indices:existsType(params)
local temp, err = self:requestEndpoint("ExistsType", params)
if err == 200 then
-- Successfull request
return true
elseif err:match("Invalid response code") then
-- Wrong response code
return false
else
-- Some other error, notify user
return nil, err
end
end

-------------------------------------------------------------------------------
-- Get Upgrade function
--
Expand Down Expand Up @@ -556,82 +522,6 @@ function Indices:validateQuery(params)
return self:requestEndpoint("ValidateQuery", params)
end

-------------------------------------------------------------------------------
-- Delete Warmer function
--
-- @usage
-- params["index"] = (list) A comma-separated list of index names to delete warmers from (supports
-- wildcards); use '_all' to perform the operation on all indices. (Required)
-- ["name"] = (list) A comma-separated list of warmer names to delete (supports wildcards); use
-- '_all' to delete all warmers in the specified indices. You must specify a name either in the uri or in the
-- parameters.
-- ["master_timeout"] = (time) Specify timeout for connection to master
--
-- @param params The delete warmer Parameters
--
-- @return table Error or the data received from the elasticsearch server
-------------------------------------------------------------------------------
function Indices:deleteWarmer(params)
return self:requestEndpoint("DeleteWarmer", params)
end

-------------------------------------------------------------------------------
-- Get Warmer function
--
-- @usage
-- params["index"] = (list) A comma-separated list of index names to restrict the operation; use
-- '_all' to perform the operation on all indices
-- ["name"] = (list) The name of the warmer (supports wildcards); leave empty to get all
-- warmers
-- ["type"] = (list) A comma-separated list of document types to restrict the operation; leave
-- empty to perform the operation on all types
-- ["ignore_unavailable"] = (boolean) Whether specified concrete indices should be ignored when unavailable
-- (missing or closed)
-- ["allow_no_indices"] = (boolean) Whether to ignore if a wildcard indices expression resolves into no
-- concrete indices. (This includes '_all' string or when no indices have been specified)
-- ["expand_wildcards"] = (enum) Whether to expand wildcard expression to concrete indices that are open,
-- closed or both. (open,closed,none,all) (default: open)
-- ["local"] = (boolean) Return local information, do not retrieve the state from master node
-- (default: false)
--
-- @param params The get warmer Parameters
--
-- @return table Error or the data received from the elasticsearch server
-------------------------------------------------------------------------------
function Indices:getWarmer(params)
return self:requestEndpoint("GetWarmer", params)
end

-------------------------------------------------------------------------------
-- Put Warmer function
--
-- @usage
-- params["index"] = (list) A comma-separated list of index names to register the warmer for; use
-- '_all' or omit to perform the operation on all indices
-- ["name"] = (string) The name of the warmer (Required)
-- ["type"] = (list) A comma-separated list of document types to register the warmer for;
-- leave empty to perform the operation on all types
-- ["master_timeout"] = (time) Specify timeout for connection to master
-- ["ignore_unavailable"] = (boolean) Whether specified concrete indices should be ignored when unavailable
-- (missing or closed) in the search request to warm
-- ["allow_no_indices"] = (boolean) Whether to ignore if a wildcard indices expression resolves into no
-- concrete indices in the search request to warm. (This includes '_all' string or when no indices have been
-- specified)
-- ["expand_wildcards"] = (enum) Whether to expand wildcard expression to concrete indices that are open,
-- closed or both, in the search request to warm. (open,closed,none,all) (default: open)
-- ["request_cache"] = (boolean) Specify whether the request to be warmed should use the request cache,
-- defaults to index level setting
-- ["body"] = The search request definition for the warmer (query, filters, facets, sorting,
-- etc)
--
-- @param params The put warmer Parameters
--
-- @return table Error or the data received from the elasticsearch server
-------------------------------------------------------------------------------
function Indices:putWarmer(params)
return self:requestEndpoint("PutWarmer", params)
end

-------------------------------------------------------------------------------
-- Function to check whether an index exists or not
--
Expand Down
8 changes: 3 additions & 5 deletions src/elasticsearch/endpoints/Bulk.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ end
-------------------------------------------------------------------------------
function Bulk:getUri()
local uri = "/_bulk"
if self.index ~= nil and self.type ~= nil then
uri = "/" .. self.index .. "/" .. self.type .. uri
elseif self.index ~= nil then
if self.index ~= nil then
uri = "/" .. self.index .. uri
elseif self.type ~= nil then
uri = "/_all/" .. self.type .. uri
else
uri = "/_all" .. uri
end
return uri
end
Expand Down
5 changes: 1 addition & 4 deletions src/elasticsearch/endpoints/Indices/DeleteMapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ function DeleteMapping:getUri()
if self.index == nil then
return nil, "index not specified for Delete Mapping"
end
if self.type == nil then
return nil, "type not specified for Delete Mapping"
end
return "/" .. self.index .. "/" .. self.type .. "/_mapping"
return "/" .. self.index .. "/_mapping"
end

-------------------------------------------------------------------------------
Expand Down
55 changes: 0 additions & 55 deletions src/elasticsearch/endpoints/Indices/DeleteWarmer.lua

This file was deleted.

58 changes: 0 additions & 58 deletions src/elasticsearch/endpoints/Indices/ExistsType.lua

This file was deleted.

3 changes: 0 additions & 3 deletions src/elasticsearch/endpoints/Indices/GetFieldMapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ function GetFieldMapping:getUri()
if self.index ~= nil then
uri = "/" .. self.index .. uri
end
if self.type ~= nil then
uri = uri .. "/" .. self.type
end

uri = uri .. "/field/" .. self.fields

Expand Down
5 changes: 1 addition & 4 deletions src/elasticsearch/endpoints/Indices/GetMapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ function GetMapping:getUri()
if self.index ~= nil then
uri = "/" .. self.index .. uri
end
if self.type ~= nil then
uri = uri .. "/" .. self.type
end


return uri
end

Expand Down
64 changes: 0 additions & 64 deletions src/elasticsearch/endpoints/Indices/GetWarmer.lua

This file was deleted.

3 changes: 0 additions & 3 deletions src/elasticsearch/endpoints/Indices/IndicesEndpoint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function IndicesEndpoint:setParams(params)
-- Clearing parameters
self.name = nil
self.index = nil
self.type = nil
self.fields = nil
self.isSynced = nil
self.feature = nil
Expand All @@ -44,8 +43,6 @@ function IndicesEndpoint:setParams(params)
self.name = v
elseif i == "index" then
self.index = v
elseif i == "type" then
self.type = v
elseif i == "fields" then
self.fields = v
elseif i == "sync" then
Expand Down
6 changes: 1 addition & 5 deletions src/elasticsearch/endpoints/Indices/PutMapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ end
-- @return string The URI
-------------------------------------------------------------------------------
function PutMapping:getUri()
if self.type == nil then
return nil, "Type not specified for Put Mapping"
end

local uri = "/_mapping/" .. self.type
local uri = "/_mapping"

if self.index ~= nil then
uri = "/" .. self.index .. uri
Expand Down
Loading

0 comments on commit 86c4979

Please sign in to comment.