Mercurial Hosting > luan
annotate examples/blog/src/lib/Db.luan @ 1389:eb8b35dccd99
cleanup and stringify change
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 03 Sep 2019 22:54:31 -0600 |
parents | 2024d23ddd64 |
children | 94f48cc76de8 |
rev | line source |
---|---|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
599
diff
changeset
|
1 local Lucene = require "luan:lucene/Lucene.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
599
diff
changeset
|
2 local Io = require "luan:Io.luan" |
596 | 3 |
4 | |
1220 | 5 local Db = {} |
596 | 6 |
1387
bc40bc9aab3a
start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1369
diff
changeset
|
7 local function completer(doc) |
bc40bc9aab3a
start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1369
diff
changeset
|
8 return doc |
bc40bc9aab3a
start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1369
diff
changeset
|
9 end |
bc40bc9aab3a
start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1369
diff
changeset
|
10 |
1224 | 11 function Db.new(lucene_dir) |
1369
709f7498a363
change Lucene.index() and add Lucene.recover()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1224
diff
changeset
|
12 local dir = Io.uri(lucene_dir) |
1387
bc40bc9aab3a
start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1369
diff
changeset
|
13 local db = Lucene.index( dir, Lucene.type.english, {"subject","content"}, completer ) |
596 | 14 |
15 -- this is how you index a field | |
16 -- db.indexed_fields.post_date = Lucene.type.long | |
17 | |
18 return db | |
19 end | |
20 | |
1224 | 21 Db.db = Db.new("site:/private/local/lucene") |
1220 | 22 |
1388
2024d23ddd64
add restore_from_postgres
Franklin Schmidt <fschmidt@gmail.com>
parents:
1387
diff
changeset
|
23 --Db.db.restore_from_postgres() |
1220 | 24 return Db |