Mercurial Hosting > luan
comparison src/luan/modules/lucene/Lucene.luan @ 1088:bae2d0c2576c
change module naming convention
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 26 Dec 2016 22:29:36 -0700 |
parents | 6b8ea0a9b7c9 |
children | 3234a14bb1f8 |
comparison
equal
deleted
inserted
replaced
1087:4aab4dd3ac9c | 1088:bae2d0c2576c |
---|---|
16 local SaneQueryParser = require "java:luan.modules.lucene.queryparser.SaneQueryParser" | 16 local SaneQueryParser = require "java:luan.modules.lucene.queryparser.SaneQueryParser" |
17 local Version = require "java:org.apache.lucene.util.Version" | 17 local Version = require "java:org.apache.lucene.util.Version" |
18 local EnglishAnalyzer = require "java:org.apache.lucene.analysis.en.EnglishAnalyzer" | 18 local EnglishAnalyzer = require "java:org.apache.lucene.analysis.en.EnglishAnalyzer" |
19 | 19 |
20 | 20 |
21 local M = {} | 21 local Lucene = {} |
22 | 22 |
23 M.instances = {} | 23 Lucene.instances = {} |
24 | 24 |
25 M.type = { | 25 Lucene.type = { |
26 string = LuceneIndex.STRING_FIELD_PARSER; | 26 string = LuceneIndex.STRING_FIELD_PARSER; |
27 integer = NumberFieldParser.INT; | 27 integer = NumberFieldParser.INT; |
28 long = NumberFieldParser.LONG; | 28 long = NumberFieldParser.LONG; |
29 double = NumberFieldParser.DOUBLE; | 29 double = NumberFieldParser.DOUBLE; |
30 | 30 |
31 english = StringFieldParser.new(EnglishAnalyzer.new(Version.LUCENE_CURRENT)) | 31 english = StringFieldParser.new(EnglishAnalyzer.new(Version.LUCENE_CURRENT)) |
32 } | 32 } |
33 | 33 |
34 M.literal = SaneQueryParser.literal | 34 Lucene.literal = SaneQueryParser.literal |
35 | 35 |
36 function M.index(index_dir,default_type,default_fields) | 36 function Lucene.index(index_dir,default_type,default_fields) |
37 local index = {} | 37 local index = {} |
38 index.dir = index_dir | 38 index.dir = index_dir |
39 local java_index = LuceneIndex.new(index_dir,default_type,default_fields) | 39 local java_index = LuceneIndex.new(index_dir,default_type,default_fields) |
40 -- index.indexed_fields = java_index.indexedFieldsMeta.newTable() | 40 -- index.indexed_fields = java_index.indexedFieldsMeta.newTable() |
41 | 41 |
64 -- index.close = java_index.close | 64 -- index.close = java_index.close |
65 index.ensure_open = java_index.ensure_open | 65 index.ensure_open = java_index.ensure_open |
66 index.next_id = java_index.nextId | 66 index.next_id = java_index.nextId |
67 index.highlighter = java_index.highlighter | 67 index.highlighter = java_index.highlighter |
68 | 68 |
69 M.instances[index] = true | 69 Lucene.instances[index] = true |
70 | 70 |
71 function index.close() | 71 function index.close() |
72 M.instances[index] = nil | 72 Lucene.instances[index] = nil |
73 java_index.close() | 73 java_index.close() |
74 end | 74 end |
75 | 75 |
76 function index.search(query, from, to, sort) | 76 function index.search(query, from, to, sort) |
77 from or error "missing 'from' parameter" | 77 from or error "missing 'from' parameter" |
167 end | 167 end |
168 | 168 |
169 return index | 169 return index |
170 end | 170 end |
171 | 171 |
172 return M | 172 return Lucene |