lucene module

The lucene module defines high level functions on top of Lucene API.

openLuceneIndex ( String indexFile {, boolean create } )

openLuceneIndex() returns a handle to read/write a Lucene index.

lc = openLuceneIndex("index")
lc . add ( elements {, Locale locale} )

add() registers an index of the specified elements, which can be either of the following type.

When locale is omiited, the value of getLocale() would be implicitly used.

lc.add("doc/test.txt", Locale::ENGLISH)
lc . delete ( String attribute, String query )

delete() deletes an index entry that the query matches the attribute.

lc.delete("path", "doc/test.txt")
lc . search ( String attribute, String query { , handler(document) } )

search() searches documents that the query matches the attribute.

for (i : lc.search("contents", "keyword")){
    println(i)
}

If handler is given, the handler is called passing the matched documents.

lc.search("contents", "keyword", function (doc) println(doc.get("path")))
lc . getDocuments ( { handler(document) } )

If handler is not given, getDocument() returns an object that generates all existing documents in the Lucene Index.

for (i : lc.getDocuments()){
   println(i)
}

If handler is specified, getDocuments() calls the handler passing the documents in the Lucene index.

lc.getDocuments(function (doc) println(doc.get("path")))