Mercurial Hosting > luan
comparison lucene/src/luan/modules/lucene/Versioning.luan @ 565:22bfd8a2eaee
do Table documentation;
replace Table.clone and Table.sub_list with Table.copy;
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 05 Jul 2015 00:47:00 -0600 |
parents | f4dfe9c64c25 |
children | 35dde32c02ab |
comparison
equal
deleted
inserted
replaced
564:c8d4d69c6dd4 | 565:22bfd8a2eaee |
---|---|
7 local String = require "luan:String" | 7 local String = require "luan:String" |
8 local matches = String.matches or error() | 8 local matches = String.matches or error() |
9 local sub = String.sub or error() | 9 local sub = String.sub or error() |
10 local string_to_number = String.to_number or error() | 10 local string_to_number = String.to_number or error() |
11 local Table = require "luan:Table" | 11 local Table = require "luan:Table" |
12 local clone = Table.clone or error() | 12 local copy = Table.copy or error() |
13 local Lucene = require "luan:lucene/Lucene" | 13 local Lucene = require "luan:lucene/Lucene" |
14 require "luan:logging/init" | 14 require "luan:logging/init" |
15 local Logging = require "luan:logging/Logging" | 15 local Logging = require "luan:logging/Logging" |
16 | 16 |
17 local logger = Logging.logger "lucene versioning" | 17 local logger = Logging.logger "lucene versioning" |
36 -- hack to deal with latest changes | 36 -- hack to deal with latest changes |
37 function M.a_big_step(db) | 37 function M.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(clone(doc)) do | 41 for field, value in pairs(copy(doc)) do |
42 if matches(field,".* index") then | 42 if matches(field,".* index") then |
43 local new_field = sub(field,1,-7) | 43 local new_field = sub(field,1,-7) |
44 db.indexed_fields[new_field] or error("field '"..new_field.."' not indexed") | 44 db.indexed_fields[new_field] or error("field '"..new_field.."' not indexed") |
45 doc[new_field] = value | 45 doc[new_field] = value |
46 doc[field] = nil | 46 doc[field] = nil |