Mercurial Hosting > luan
comparison src/luan/modules/lucene/Versioning.luan @ 1088:bae2d0c2576c
change module naming convention
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 26 Dec 2016 22:29:36 -0700 |
parents | 1a68fc55a80c |
children | 7f4a12fb7716 |
comparison
equal
deleted
inserted
replaced
1087:4aab4dd3ac9c | 1088:bae2d0c2576c |
---|---|
15 local Logging = require "luan:logging/Logging.luan" | 15 local Logging = require "luan:logging/Logging.luan" |
16 | 16 |
17 local logger = Logging.logger "lucene versioning" | 17 local logger = Logging.logger "lucene versioning" |
18 | 18 |
19 | 19 |
20 local M = {} | 20 local Versioning = {} |
21 | 21 |
22 function M.update(db,steps,version) | 22 function Versioning.update(db,steps,version) |
23 local doc = db.get_document"type:version" or { type="version", version=integer(0) } | 23 local doc = db.get_document"type:version" or { type="version", version=integer(0) } |
24 while doc.version < version do | 24 while doc.version < version do |
25 doc.version = integer(doc.version + 1) | 25 doc.version = integer(doc.version + 1) |
26 logger.error("step "..doc.version) | 26 logger.error("step "..doc.version) |
27 db.update_in_transaction( function() | 27 db.update_in_transaction( function() |
32 end | 32 end |
33 end | 33 end |
34 | 34 |
35 | 35 |
36 -- hack to deal with latest changes | 36 -- hack to deal with latest changes |
37 function M.a_big_step(db) | 37 function Versioning.a_big_step(db) |
38 db.indexed_fields["id index"] = Lucene.type.string | 38 db.indexed_fields["id index"] = Lucene.type.string |
39 db.advanced_search( Lucene.literal"id index" .. ":*", function(_,doc_fn) | 39 db.advanced_search( Lucene.literal"id index" .. ":*", function(_,doc_fn) |
40 local doc = doc_fn() | 40 local doc = doc_fn() |
41 for field, value in pairs(copy(doc)) do | 41 for field, value in pairs(copy(doc)) do |
42 if matches(field," index$") then | 42 if matches(field," index$") then |
51 end ) | 51 end ) |
52 db.indexed_fields["type index"] = Lucene.type.string | 52 db.indexed_fields["type index"] = Lucene.type.string |
53 db.delete( Lucene.literal"type index" .. ":*" ) | 53 db.delete( Lucene.literal"type index" .. ":*" ) |
54 end | 54 end |
55 | 55 |
56 return M | 56 return Versioning |