setokk opened a new issue, #12968:
URL: https://github.com/apache/lucene/issues/12968
### Description
Hello!
I use the FSDirectory.open(Path path) method when building the index.
When I run this method while **not** being in a jar, it works as intended.
But as soon as I package into a .jar file, it gets stuck at
FSDirectory.open(Path path).
I outputted the absolute paths of the files (dataFile and idxDir) and they
were correct.
The weird thing is no exception is thrown. It just gets stuck. The method is
called in the background from a SwingWorker but that shouldn't affect it really
since it works well when I just run it from my IDE.
Not 100% sure if this is a bug but it seems weird that it just gets stuck
and nothing is thrown while the file paths are correct.
Thanks for reading!
Here is my search engine init method:
```
public static void init(boolean clearIndex) {
File dataFile = new File(System.getProperty("user.dir") +
File.seperator + "data.txt");
File idxDir = new File(System.getProperty("user.dir") +
File.seperator + "index");
// Set up analyzer
SearchEngine.analyzer = new EnglishAnalyzer();
try {
System.out.println(idxDir.getAbsolutePath());
System.out.println(dataFile.getAbsolutePath());
SearchEngine.indexDir = FSDirectory.open(idxDir.toPath());
if (clearIndex) {
System.out.println("Rebuilding index...");
IndexWriterConfig idxConfig = new
IndexWriterConfig(SearchEngine.analyzer);
idxConfig.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
IndexWriter idxWriter = new IndexWriter(indexDir, idxConfig);
// Now, populate the index
int docs = 0;
JsonParser jParser = new JsonParser();
for (String line : Files.readAllLines(dataFile.toPath(),
StandardCharsets.UTF_8)) {
// On large amounts of data, this can take a while
if (docs % 10000 == 0) {
System.out.println(docs);
}
docs++;
// Parse JSON
// Each line of the input file is a serialized JSON
object
Map j = jParser.parse(line);
// Get title
String title = (String) j.get("title");
// Get description
String ab = (String) j.get("abstract");
// Iterate through each author object and get "surname"
and "given_names"
List<Map<String, String>> authors = (List<Map<String,
String>>) j.get("authors");
StringBuilder authorsConcat = new StringBuilder();
String prefix = "";
for (Map<String, String> author : authors) {
String surname = author.get("surname");
String givenNames = author.get("given_names");
// Concatenate surname and given names to create
author's full name
String fullName = prefix + givenNames + " " +
surname;
prefix = ", ";
authorsConcat.append(fullName);
}
// Get pmid
String pmid = (String) j.get("pmid");
// Get biblio
Map biblio = (Map) j.get("biblio");
// Get biblio->year
String year = (String) biblio.get("year");
// Get biblio->volume
String volume = (String) biblio.get("volume");
// Get biblio->issue
String issue = (String) biblio.get("issue");
// Get biblio->fpage
String fpage = (String) biblio.get("fpage");
// Get biblio-lpage
String lpage = (String) biblio.get("lpage");
// Get journal
Map journal = (Map) biblio.get("journal");
// Get journal->title
String jTitle = (String) journal.get("title");
// Get journal->issn
String issn = (String) journal.get("issn");
// Indexed fields
Field tiField = new Field("title", title,
TextField.TYPE_STORED);
Field abField = new Field("abstract", ab,
TextField.TYPE_STORED);
// Not indexed fields
StoredField auField = new StoredField("authors",
authorsConcat.toString());
StoredField pmidField = new StoredField("pmid", pmid);
StoredField volumeField = new StoredField("volume",
volume);
StoredField issueField = new StoredField("issue", issue);
StoredField fpageField = new StoredField("fpage", fpage);
StoredField lpageField = new StoredField("lpage", lpage);
StoredField jTitleField = new StoredField("jTitle",
jTitle);
StoredField issnField = new StoredField("issn", issn);
Document thisDoc = new Document();
thisDoc.add(tiField);
thisDoc.add(abField);
thisDoc.add(auField);
thisDoc.add(pmidField);
thisDoc.add(volumeField);
thisDoc.add(issueField);
thisDoc.add(fpageField);
thisDoc.add(lpageField);
thisDoc.add(jTitleField);
thisDoc.add(issnField);
idxWriter.addDocument(thisDoc);
}
System.out.println("Done!");
System.out.println(docs + " documents indexed.");
idxWriter.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
```
### Version and environment details
OS: Windows 10, Arch Linux
Lucene Version: Lucene 9.8.0
JDK Version: openjdk 21.0.1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]