You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by se...@apache.org on 2019/02/03 23:09:52 UTC
svn commit: r1852859 - in /comdev/helpwanted.apache.org/site:
admin/elastic.lua lib/elastic.lua
Author: sebb
Date: Sun Feb 3 23:09:51 2019
New Revision: 1852859
URL: http://svn.apache.org/viewvc?rev=1852859&view=rev
Log:
Unused
Modified:
comdev/helpwanted.apache.org/site/admin/elastic.lua
comdev/helpwanted.apache.org/site/lib/elastic.lua
Modified: comdev/helpwanted.apache.org/site/admin/elastic.lua
URL: http://svn.apache.org/viewvc/comdev/helpwanted.apache.org/site/admin/elastic.lua?rev=1852859&r1=1852858&r2=1852859&view=diff
==============================================================================
--- comdev/helpwanted.apache.org/site/admin/elastic.lua (original)
+++ comdev/helpwanted.apache.org/site/admin/elastic.lua Sun Feb 3 23:09:51 2019
@@ -25,7 +25,7 @@ local config = {
}
local default_doc = "item"
--- Standard ES query, returns $size results of any doc of type $doc, sorting by $sitem
+-- Standard ES query, returns $size results of any doc of type $doc, sorting by $sitem (desc)
local function getHits(query, size, doc, sitem)
doc = doc or default_doc
sitem = sitem or "epoch"
@@ -55,43 +55,6 @@ local function getDoc (ty, id)
return (json and json._source) and json._source or {}
end
--- Get results (a'la getHits), but only return email headers, not the body
--- provides faster transport when we don't need everything
-local function getHeaders(query, size, doc)
- doc = doc or default_doc
- size = size or 10
- query = query:gsub(" ", "+")
- local url = config.es_url .. doc .. "/_search?_source_exclude=body&q="..query.."&sort=date:desc&size=" .. size
- local result = http.request(url)
- local json = JSON.decode(result)
- local out = {}
- if json and json.hits and json.hits.hits then
- for k, v in pairs(json.hits.hits) do
- v._source.request_id = v._id
- table.insert(out, v._source)
- end
- end
- return out
-end
-
--- Same as above, but reverse return order
-local function getHeadersReverse(query, size, doc)
- doc = doc or default_doc
- size = size or 10
- query = query:gsub(" ", "+")
- local url = config.es_url .. doc .. "/_search?_source_exclude=body&q="..query.."&sort=epoch:desc&size=" .. size
- local result = http.request(url)
- local json = JSON.decode(result)
- local out = {}
- if json and json.hits and json.hits.hits then
- for k, v in pairs(json.hits.hits) do
- v._source.request_id = v._id
- table.insert(out, 1, v._source)
- end
- end
- return out
-end
-
-- Do a raw ES query with a JSON query
local function raw(query, doctype)
local js = JSON.encode(query)
@@ -124,18 +87,11 @@ local function index(r, id, ty, body)
return json or {}
end
-local function setDefault(typ)
- default_doc = typ
-end
-
-- module defs
return {
find = getHits,
- findFast = getHeaders,
- findFastReverse = getHeadersReverse,
get = getDoc,
raw = raw,
index = index,
- default = setDefault,
update = update
}
Modified: comdev/helpwanted.apache.org/site/lib/elastic.lua
URL: http://svn.apache.org/viewvc/comdev/helpwanted.apache.org/site/lib/elastic.lua?rev=1852859&r1=1852858&r2=1852859&view=diff
==============================================================================
--- comdev/helpwanted.apache.org/site/lib/elastic.lua (original)
+++ comdev/helpwanted.apache.org/site/lib/elastic.lua Sun Feb 3 23:09:51 2019
@@ -25,7 +25,7 @@ local config = {
}
local default_doc = "item"
--- Standard ES query, returns $size results of any doc of type $doc, sorting by $sitem
+-- Standard ES query, returns $size results of any doc of type $doc, sorting by $sitem (desc)
local function getHits(query, size, doc, sitem)
doc = doc or default_doc
sitem = sitem or "epoch"
@@ -55,43 +55,6 @@ local function getDoc (ty, id)
return (json and json._source) and json._source or {}
end
--- Get results (a'la getHits), but only return email headers, not the body
--- provides faster transport when we don't need everything
-local function getHeaders(query, size, doc)
- doc = doc or default_doc
- size = size or 10
- query = query:gsub(" ", "+")
- local url = config.es_url .. doc .. "/_search?_source_exclude=body&q="..query.."&sort=date:desc&size=" .. size
- local result = http.request(url)
- local json = JSON.decode(result)
- local out = {}
- if json and json.hits and json.hits.hits then
- for k, v in pairs(json.hits.hits) do
- v._source.request_id = v._id
- table.insert(out, v._source)
- end
- end
- return out
-end
-
--- Same as above, but reverse return order
-local function getHeadersReverse(query, size, doc)
- doc = doc or default_doc
- size = size or 10
- query = query:gsub(" ", "+")
- local url = config.es_url .. doc .. "/_search?_source_exclude=body&q="..query.."&sort=epoch:desc&size=" .. size
- local result = http.request(url)
- local json = JSON.decode(result)
- local out = {}
- if json and json.hits and json.hits.hits then
- for k, v in pairs(json.hits.hits) do
- v._source.request_id = v._id
- table.insert(out, 1, v._source)
- end
- end
- return out
-end
-
-- Do a raw ES query with a JSON query
local function raw(query, doctype)
local js = JSON.encode(query)
@@ -124,18 +87,11 @@ local function index(r, id, ty, body)
return json or {}
end
-local function setDefault(typ)
- default_doc = typ
-end
-
-- module defs
return {
find = getHits,
- findFast = getHeaders,
- findFastReverse = getHeadersReverse,
get = getDoc,
raw = raw,
index = index,
- default = setDefault,
update = update
}