You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by "McGibbney, Lewis John" <Le...@gcu.ac.uk> on 2010/11/25 13:37:21 UTC

IndexWriter Class

Hello List,

Lucene 3.0.1
Windows Vista Premium Home Edition

I am currently attempting to configure my IndexFiles.java file. My intention is to add the following functionality to the code as I require input text to be further analyzed than what the default analyzer does.


IndexWriter writer = new IndexWriter(FSDirectory.open(INDEX_DIR),

new NGramTokenFilter(

new LowerCaseFilter(

new StandardFilter(

new StandardTokenizer

(Version.LUCENE_CURRENT, null)))), true,

IndexWriter.MaxFieldLength.LIMITED);

System.out.println("Indexing to directory '" +INDEX_DIR+ "'...");

indexDocs(writer, docDir);

System.out.println("Optimizing...");

writer.optimize();

writer.close();

Date end = new Date();

System.out.println(end.getTime() - start.getTime() + " total milliseconds");



My problem lies in the IndexWriter class and the number of analyzer's/tokenizer's I am permitted to pass as parameters and I find that this is slightly unclear from the javadocs. Are there any existing resources to solve this problem? or can someone help me out please.



Anything would be greatly appreciated.



Lews Mc

Glasgow Caledonian University is a registered Scottish charity, number SC021474

Winner: Times Higher Education's Widening Participation Initiative of the Year 2009 and Herald Society's Education Initiative of the Year 2009
http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,en.html

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: IndexWriter Class

Posted by Michael McCandless <lu...@mikemccandless.com>.
Please don't hijack threads; start a new thread instead.

Mike

2010/11/28 jiandong yang <jd...@gmail.com>:
> hello, all, here comes my question:
> as far as I know,  lucene now offer the feature that ones can search some
> doc while the index which contains that specific doc is modifying.
> for example(pseudocode) :
>
> while indexWriter(indexDir).add(docA)  is doing, can indexReader(indexDir)
> offer the query function?
>
> after the add is done, should the reader be reopen?
>
> or someone show me a simple example, thx a lot!!!
>
> --
> 祝一切顺利~
>
> Best Regards,
>
> 杨建东
>
> =====================================================
>
> Jiandong Yang
> Mobile Phone:15921536660
> email: yangjiandong@snda.com
> Architect management office
>
>
> Shanghai shanda networking development Co., LTD
>
> Shanghai 201203, P. R. China
>
> =====================================================
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: IndexWriter Class

Posted by jiandong yang <jd...@gmail.com>.
hello, all, here comes my question:
as far as I know,  lucene now offer the feature that ones can search some
doc while the index which contains that specific doc is modifying.
for example(pseudocode) :

while indexWriter(indexDir).add(docA)  is doing, can indexReader(indexDir)
offer the query function?

after the add is done, should the reader be reopen?

or someone show me a simple example, thx a lot!!!

-- 
祝一切顺利~

Best Regards,

杨建东

=====================================================

Jiandong Yang
Mobile Phone:15921536660
email: yangjiandong@snda.com
Architect management office


Shanghai shanda networking development Co., LTD

Shanghai 201203, P. R. China

=====================================================

Re: IndexWriter Class

Posted by Ian Lea <ia...@gmail.com>.
The normal technique is to write your own analyzer.  See
http://wiki.apache.org/lucene-java/LuceneFAQ#How_do_I_write_my_own_Analyzer.3F.
 Then pass that to IndexWriter - and be sure to use the same analyzer
when you are searching, unless you're doing clever things.

--
Ian.


On Thu, Nov 25, 2010 at 12:37 PM, McGibbney, Lewis John
<Le...@gcu.ac.uk> wrote:
> Hello List,
>
> Lucene 3.0.1
> Windows Vista Premium Home Edition
>
> I am currently attempting to configure my IndexFiles.java file. My intention is to add the following functionality to the code as I require input text to be further analyzed than what the default analyzer does.
>
>
> IndexWriter writer = new IndexWriter(FSDirectory.open(INDEX_DIR),
>
> new NGramTokenFilter(
>
> new LowerCaseFilter(
>
> new StandardFilter(
>
> new StandardTokenizer
>
> (Version.LUCENE_CURRENT, null)))), true,
>
> IndexWriter.MaxFieldLength.LIMITED);
>
> System.out.println("Indexing to directory '" +INDEX_DIR+ "'...");
>
> indexDocs(writer, docDir);
>
> System.out.println("Optimizing...");
>
> writer.optimize();
>
> writer.close();
>
> Date end = new Date();
>
> System.out.println(end.getTime() - start.getTime() + " total milliseconds");
>
>
>
> My problem lies in the IndexWriter class and the number of analyzer's/tokenizer's I am permitted to pass as parameters and I find that this is slightly unclear from the javadocs. Are there any existing resources to solve this problem? or can someone help me out please.
>
>
>
> Anything would be greatly appreciated.
>
>
>
> Lews Mc
>
> Glasgow Caledonian University is a registered Scottish charity, number SC021474
>
> Winner: Times Higher Education's Widening Participation Initiative of the Year 2009 and Herald Society's Education Initiative of the Year 2009
> http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,en.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org