-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👻 Improve maven.default.index gen (#64)
Signed-off-by: Jason Montleon <[email protected]>
- Loading branch information
Showing
2 changed files
with
28 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,44 @@ | ||
import java.io.BufferedWriter; | ||
import java.io.FileWriter; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.TreeSet; | ||
import java.util.Iterator; | ||
import java.util.Set; | ||
import org.apache.lucene.document.Document; | ||
import org.apache.lucene.index.DirectoryReader; | ||
import org.apache.lucene.index.IndexReader; | ||
import org.apache.lucene.index.StoredFields; | ||
import org.apache.lucene.store.Directory; | ||
import org.apache.lucene.store.FSDirectory; | ||
|
||
public class Export { | ||
public class export { | ||
public static void main(String[] args) throws Exception { | ||
Path path = Paths.get("index"); | ||
Directory index = FSDirectory.open(path); | ||
DirectoryReader dreader = DirectoryReader.open(index); | ||
IndexReader reader = DirectoryReader.open(index); | ||
StoredFields storedFields = reader.storedFields(); | ||
|
||
TreeSet<String> groupIds = new TreeSet<String>(); | ||
|
||
int num = reader.numDocs(); | ||
for ( int i = 0; i < num; i++) | ||
for (int i = 0; i < num; i++) | ||
{ | ||
Document d = reader.document( i); | ||
System.out.println( "d=" +d); | ||
Document d = storedFields.document(i); | ||
if (d.get("u") != null) { | ||
groupIds.add(d.get("u").split("\\|")[0] + ".*"); | ||
} | ||
} | ||
|
||
BufferedWriter out = new BufferedWriter(new FileWriter("maven.default.index")); | ||
Iterator it = groupIds.iterator(); | ||
while(it.hasNext()) { | ||
out.write(it.next().toString()); | ||
out.newLine(); | ||
} | ||
|
||
out.close(); | ||
reader.close(); | ||
} | ||
} |