[jsword-devel] jsword-devel Digest, Vol 46, Issue 15
DM Smith
dmsmith555 at yahoo.com
Thu Apr 3 07:44:24 MST 2008
Yiguang,
To index a book you need to get an IndexManager from the IndexManagerFactory
IndexManager indexManager = IndexManagerFactory.getIndexManager();
You can then check to see if there already is an index and if not then
create it as a background Job.
if (!indexManager.isIndexed(book))
{
indexManager.scheduleIndexCreation(book);
}
You can also delete an index
if (indexManager.isIndexed(book))
{
indexManager.deleteIndex(book);
}
Index creation is a background Job that can be monitored by adding a
WorkListener for WorkEvents. See o.c.c.progress.swing.JobsProgressBar
for a model that could be used to create feedback to standard out.
If all you care about is when the index is changed you can add an
IndexStatusListener with something like:
book.addIndexStatusListener(new IndexStatusListener() {
public void statusChanged(IndexStatusEvent ev)
{
// respond to index change
if (indexManager.isIndexed(book))
{
done = true;
}
}
});
Perhaps spinning until done with some thing like
while (!done)
{
sleep
}
I'll see about throwing together an example class (in
o.c.j.book.examples) called ManageIndex that does this.
Yours in Christ,
DM
Yiguang Hu wrote:
> DM,
>
> Thanks. Yes. The tomcat will be under a dedicated user
> eventually.
> I will setup the configure file for jsword so it will
> know where to look at stuff according to the
> configure.
> I mean the "standalone code" is piece of code I can
> run to generate the index after I unzip the "bible"
> module into the appropriate directory, yes a segment
> of code showing how to build index is what I mean
> exactly. I am trying to make the process work on a
> linux concole without X so no bibledesktop there.
> In Him,
>
> Yiguang
> --- DM Smith <dmsmith555 at yahoo.com> wrote:
>
>
>> Yiguang,
>> I'm glad Peter was able to give you the right answer
>> regarding the
>> placement of the modules and also of their indexes.
>>
>> I'm concerned that JSword is running via tomcat as
>> root. This appears
>> to give JSword root permissions. Not a good idea.
>>
>> Alternatively, if you can set the Java properties
>> user.home,
>> sword.home or jsword.home, you can influence where
>> JSword looks for
>> it's files.
>> user.home is where JSword thinks the user's home
>> directory is.
>> sword.home is where JSword thinks the user's
>> writable module directory
>> is.
>> jsword.home is where JSword thinks the user's
>> writable program
>> directory is.
>> If the latter two are not defined or are not
>> writable, then JSword
>> will use a platform dependent determination of the
>> module and program
>> homes.
>>
>> On Unix, it would be ~/.sword and ~/.jsword
>> respectively.
>>
>> As Peter noted, JSword is exceptionally good at
>> finding many SWORD
>> module directories.
>>
>> The SWORD architecture has the index co-located with
>> the module's
>> files. We didn't do this because in many cases these
>> locations are
>> shared and not writable. So we put them in the
>> JSword writable area.
>> Because Lucene (in Java) is so far ahead of CLucene
>> and because JSword
>> uses different analyzers, JSword and SWORD cannot
>> use each others
>> indexes.
>>
>> I'm not sure what you mean by "to get the index
>> build may be through
>> standalone java program"? Do you need a fragment to
>> explain how to
>> build an index? Or do you want to use BibleDesktop
>> to build the index
>> then manually copy it to where it needs to be?
>>
>> In Him,
>> DM
>>
>>
>>
>> On Mar 29, 2008, at 12:10 AM, Yiguang Hu wrote:
>>
>>
>>> Thanks Peter.
>>>
>>> After I copied the index under Sword/* on my
>>>
>> windows
>>
>>> box into the corresponding location on linux the
>>> search start to work!
>>>
>>> I will be just waiting for DM to show me where to
>>>
>> get
>>
>>> the index build may be through a standalone java
>>> program.
>>>
>>> Yiguang
>>> --- peter <refdoc at gmx.net> wrote:
>>>
>>>
>>>> Sorry Yiguang,
>>>>
>>>> Thsi is beyond me. I think you need to wait until
>>>>
>> DM
>>
>>>> is again fully
>>>> available - one week or so more.
>>>>
>>>> The only comment I have is that before you run
>>>> searches on BD you need
>>>> to have build the lucene index.
>>>>
>>>> I am not sure how you would trigger this in your
>>>>
>> own
>>
>>>> scenario, but I
>>>> think you could simply create those index on a BD
>>>> installation and then
>>>> copy them over.
>>>>
>>>> They will be in ~/.jsword/lucene/Sword/<book> and
>>>> can simply be copied IIRC.
>>>>
>>>> Peter
>>>> Yiguang Hu wrote:
>>>>
>>>>> Thanks Peter.
>>>>> I unzipped AB.zip under /root/.sword and I can
>>>>>
>> see
>>
>>>> the
>>>>
>>>>> book name show up on my book selection drop down
>>>>>
>>>> list.
>>>>
>>>>> But when I use that book for search I got the
>>>>> following semiliar error in the tomcat log. The
>>>>> directory /root/.jsword/lucene/Sword/AB is
>>>>>
>> empty.
>>
>>>>> Any input would be appreciated.
>>>>> Thanks
>>>>> Yiguang
>>>>>
>>>>> INFO: second load failure
>>>>> java.io.FileNotFoundException: no segments* file
>>>>>
>>>> found
>>>>
>>>>> in
>>>>>
>>>>>
> org.apache.lucene.store.FSDirectory@/root/.jsword/lucene/Sword/AB:
>
>>>>> files:
>>>>> at
>>>>>
>>>>>
>>> org.apache.lucene.index.SegmentInfos
>>> $FindSegmentsFile.run(SegmentInfos.java:516)
>>>
>>>>> at
>>>>>
>>>>>
> org.apache.lucene.index.IndexReader.open(IndexReader.java:185)
>
>>>>> at
>>>>>
>>>>>
> org.apache.lucene.index.IndexReader.open(IndexReader.java:148)
>
>>>>> at
>>>>>
>>>>>
> org.apache.lucene.search.IndexSearcher.<init>(IndexSearcher.java:48)
>
>>>>> at
>>>>>
>>>>>
>>> org
>>>
>>>
> ..crosswire.jsword.index.lucene.LuceneIndex.activate(LuceneIndex.java:
>
>>> 303)
>>>
>>>>> at
>>>>>
>>>>>
> org.crosswire.common.activate.Activator.activate(Activator.java:57)
>
>>>>> at
>>>>>
>>>>>
>>> org
>>> .crosswire
>>>
>>>
> ..jsword.index.lucene.LuceneIndex.checkActive(LuceneIndex.java:338)
>
>>>>> at
>>>>>
>>>>>
> org.crosswire.jsword.index.lucene.LuceneIndex.find(LuceneIndex.java:
>
>>> 200)
>>>
>>>>> at
>>>>>
>>>>>
> org.crosswire.jsword.index.query.BaseQuery.find(BaseQuery.java:53)
>
>>>>> at
>>>>>
>>>>>
>>> org
>>> .crosswire
>>>
>>>
> ..jsword.index.lucene.LuceneSearcher.search(LuceneSearcher.java:86)
>
>>>>> at
>>>>>
>>>>>
>>> org
>>> .crosswire
>>>
>>>
> ..jsword.index.lucene.LuceneSearcher.search(LuceneSearcher.java:76)
>
>>>>> at
>>>>>
>>>>>
> org.crosswire.jsword.book.basic.AbstractBook.find(AbstractBook.java:
>
>>> 116)
>>>
>>>>> at
>>>>>
>>>>>
> org.crosswire.jsword.book.basic.AbstractBook.find(AbstractBook.java:
>
>>
> === message truncated ===
>
>
>
> ____________________________________________________________________________________
> You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
> http://tc.deals.yahoo.com/tc/blockbuster/text5.com
>
>
>
More information about the jsword-devel
mailing list