annotate examples/blog/src/lib/Db.luan @ 1324:1660136ac451

website - remove Shared.luan
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 07 Feb 2019 22:38:46 -0700
parents 4416b9cbebf9
children 709f7498a363
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4
1220
4721c482c86b cleaner Db example
Franklin Schmidt <fschmidt@gmail.com>
parents: 1088
diff changeset
5 local Db = {}
596
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6
1224
Franklin Schmidt <fschmidt@gmail.com>
parents: 1220
diff changeset
7 function Db.new(lucene_dir)
1220
4721c482c86b cleaner Db example
Franklin Schmidt <fschmidt@gmail.com>
parents: 1088
diff changeset
8 local dir = Io.uri(lucene_dir).to_string()
599
50540f0813e2 support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents: 596
diff changeset
9 local db = Lucene.index( dir, Lucene.type.english, {"subject","content"} )
596
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 -- this is how you index a field
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 -- db.indexed_fields.post_date = Lucene.type.long
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 return db
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 end
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16
1224
Franklin Schmidt <fschmidt@gmail.com>
parents: 1220
diff changeset
17 Db.db = Db.new("site:/private/local/lucene")
1220
4721c482c86b cleaner Db example
Franklin Schmidt <fschmidt@gmail.com>
parents: 1088
diff changeset
18
4721c482c86b cleaner Db example
Franklin Schmidt <fschmidt@gmail.com>
parents: 1088
diff changeset
19 return Db