[prev in list] [next in list] [prev in thread] [next in thread]
List: jedit-cvs
Subject: [ jEdit-commits ] SF.net SVN: jedit:[15335]
From: shlomy () users ! sourceforge ! net
Date: 2009-05-23 13:50:43
Message-ID: E1M7rcZ-0006AU-Gv () 3kljzd1 ! ch3 ! sourceforge ! com
[Download RAW message or body]
Revision: 15335
http://jedit.svn.sourceforge.net/jedit/?rev=15335&view=rev
Author: shlomy
Date: 2009-05-23 13:50:43 +0000 (Sat, 23 May 2009)
Log Message:
-----------
Added the list of indexed directories to the Lucene database.
Modified Paths:
--------------
plugins/LucenePlugin/trunk/src/lucene/LucenePlugin.java
Modified: plugins/LucenePlugin/trunk/src/lucene/LucenePlugin.java
===================================================================
--- plugins/LucenePlugin/trunk/src/lucene/LucenePlugin.java 2009-05-23 13:27:02 UTC \
(rev 15334)
+++ plugins/LucenePlugin/trunk/src/lucene/LucenePlugin.java 2009-05-23 13:50:43 UTC \
(rev 15335) @@ -13,6 +13,8 @@
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriter.MaxFieldLength;
import org.apache.lucene.queryParser.ParseException;
@@ -56,6 +58,10 @@
"lucene-search");
sr.search(text);
}
+ private static String indexMetaDir()
+ {
+ return OptionPane.indexPath() + File.separator + "indexMeta";
+ }
private static String contentDir()
{
return OptionPane.indexPath() + File.separator + "content";
@@ -64,6 +70,21 @@
{
return OptionPane.indexPath() + File.separator + "meta";
}
+ public static void showIndexedDirs(View view)
+ {
+ try {
+ IndexReader r = IndexReader.open(indexMetaDir());
+ for (int i = 0; i < r.numDocs(); i++)
+ {
+ Document doc = r.document(i);
+ System.err.println(doc.get("dir"));
+ }
+ } catch (CorruptIndexException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
public static void index(View view) {
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@@ -73,6 +94,9 @@
return;
String dir = fc.getSelectedFile().getPath();
try {
+ IndexWriter indexMetaWriter = new IndexWriter(indexMetaDir(),
+ analyzer, MaxFieldLength.UNLIMITED);
+ indexMetaWriter.addDocument(createIndexMetaDocument(dir));
IndexWriter contentWriter = new IndexWriter(contentDir(),
analyzer, MaxFieldLength.UNLIMITED);
IndexWriter metaWriter = new IndexWriter(metaDir(),
@@ -80,6 +104,7 @@
makeIndex(metaWriter, contentWriter, dir);
contentWriter.close();
metaWriter.close();
+ indexMetaWriter.close();
} catch (Exception e) {
e.printStackTrace();
return;
@@ -132,12 +157,20 @@
private static Document createFileDocument(File f)
{
Document doc = new Document();
- doc.add(new Field("file", f.getPath(), Field.Store.YES, Field.Index.NO));
- doc.add(new Field("modified", String.valueOf(f.lastModified()), Field.Store.YES, \
Field.Index.NO));
- doc.add(new Field("indexed", String.valueOf(System.currentTimeMillis()), \
Field.Store.YES, Field.Index.NO)); + doc.add(new Field("file", f.getPath(), \
Field.Store.YES, + Field.Index.NOT_ANALYZED));
+ doc.add(new Field("modified", String.valueOf(f.lastModified()), Field.Store.YES,
+ Field.Index.NO));
+ doc.add(new Field("indexed", String.valueOf(System.currentTimeMillis()),
+ Field.Store.YES, Field.Index.NOT_ANALYZED));
return doc;
}
-
+ private static Document createIndexMetaDocument(String dir)
+ {
+ Document doc = new Document();
+ doc.add(new Field("dir", dir, Field.Store.YES, Field.Index.NOT_ANALYZED));
+ return doc;
+ }
public void start() {
}
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com
_______________________________________________
jEdit-CVS mailing list
jEdit-CVS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jedit-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic