Mercurial Hosting > shareasale
comparison src/lib/Db.luan @ 1:bd2abcd7190a
mostly done
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Tue, 20 Sep 2022 19:40:39 -0600 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:6b17b5030868 | 1:bd2abcd7190a |
|---|---|
| 1 local Luan = require "luan:Luan.luan" | |
| 2 local error = Luan.error | |
| 3 local Io = require "luan:Io.luan" | |
| 4 local uri = Io.uri or error() | |
| 5 local Table = require "luan:Table.luan" | |
| 6 local concat = Table.concat or error() | |
| 7 local Lucene = require "luan:lucene/Lucene.luan" | |
| 8 local Shared = require "site:/lib/Shared.luan" | |
| 9 local to_list = Shared.to_list or error() | |
| 10 | |
| 11 | |
| 12 local function supplementer(doc) | |
| 13 local t = {} | |
| 14 t[#t+1] = doc.user_name | |
| 15 if doc.category ~= nil then | |
| 16 t[#t+1] = concat(to_list(doc.category)," ") | |
| 17 end | |
| 18 t[#t+1] = doc.description | |
| 19 return { | |
| 20 free = concat(t," ") | |
| 21 } | |
| 22 end | |
| 23 | |
| 24 local dir = uri("site:/lucene") | |
| 25 | |
| 26 local options = { | |
| 27 supplementer = supplementer | |
| 28 default_type = Lucene.type.english | |
| 29 default_fields = {"free"} | |
| 30 } | |
| 31 | |
| 32 local Db = Lucene.index(dir,options) | |
| 33 | |
| 34 Db.indexed_fields.free = Lucene.type.english | |
| 35 Db.indexed_fields.user_id = Lucene.type.string | |
| 36 Db.indexed_fields.user_name = Lucene.type.english | |
| 37 Db.indexed_fields.category = Lucene.type.english | |
| 38 Db.indexed_fields.description = Lucene.type.english | |
| 39 | |
| 40 return Db |
