comparison examples/blog/src/lib/Db.luan @ 1395:9dfff82dfc59

finish postgres work
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 09 Sep 2019 01:22:23 -0600
parents cc0dbca576dc
children a5f61890ad84
comparison
equal deleted inserted replaced
1394:8fe777ba5045 1395:9dfff82dfc59
6 6
7 7
8 local Db = {} 8 local Db = {}
9 9
10 local postgres_spec = Hosting.postgres_spec and Hosting.postgres_spec() 10 local postgres_spec = Hosting.postgres_spec and Hosting.postgres_spec()
11 if postgres_spec ~= nil then 11
12 function postgres_spec.completer(doc) 12 local function completer(doc)
13 return doc 13 return doc
14 end
15 end 14 end
16 15
17 function Db.new(lucene_dir) 16 function Db.new(lucene_dir)
18 local dir = Io.uri(lucene_dir) 17 local dir = Io.uri(lucene_dir)
19 local db = Lucene.index( dir, Lucene.type.english, {"subject","content"}, postgres_spec ) 18 local db = Lucene.index( dir, {
19 default_type = Lucene.type.english
20 default_fields = {"subject","content"}
21 completer = completer
22 postgres_spec = postgres_spec
23 } )
20 24
21 -- this is how you index a field 25 -- this is how you index a field
22 -- db.indexed_fields.post_date = Lucene.type.long 26 -- db.indexed_fields.post_date = Lucene.type.long
23 27
24 return db 28 return db