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 2023/03/19 00:06:56 UTC

svn commit: r1908506 - /comdev/helpwanted.apache.org/site/listitems.lua

Author: sebb
Date: Sun Mar 19 00:06:56 2023
New Revision: 1908506

URL: http://svn.apache.org/viewvc?rev=1908506&view=rev
Log:
Sync with tasks.lua

Modified:
    comdev/helpwanted.apache.org/site/listitems.lua

Modified: comdev/helpwanted.apache.org/site/listitems.lua
URL: http://svn.apache.org/viewvc/comdev/helpwanted.apache.org/site/listitems.lua?rev=1908506&r1=1908505&r2=1908506&view=diff
==============================================================================
--- comdev/helpwanted.apache.org/site/listitems.lua (original)
+++ comdev/helpwanted.apache.org/site/listitems.lua Sun Mar 19 00:06:56 2023
@@ -30,9 +30,26 @@ function handle(r)
     if get.id then
         local doc = nil
         if #get.id == 8 and get.id:match("^([a-f0-9]+)$") then
-            docs = elastic.find('_id:' .. get.id .. "*", 1, 'item', 'created')
-            if docs and #docs == 1 then
-                doc = docs[1]
+--        Cannot use wild-card matching on _id field
+--            docs = elastic.find('_id:' .. get.id .. "*", 1, 'item', 'created')
+--            if docs and #docs == 1 then
+--                doc = docs[1]
+--            end
+            local json
+--          Find all the ids
+            json = elastic.raw {
+                _source = false,
+                size = 250
+            }
+            if json and json.hits and json.hits.hits then
+                for k, v in pairs(json.hits.hits) do
+--                  Find the first matching id
+--                  Should check for multiple matches, but the original code does not either ...
+                    if string.sub(v._id,1,8) == get.id then
+                        doc = elastic.get('item', v._id)
+                        break
+                    end
+                end
             end
         else 
             doc = elastic.get('item', get.id)