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 Boris Galitsky <bg...@rambler.ru> on 2006/09/22 02:34:09 UTC
analyzer to populate more that one field of Lucene document
I need to create two fields for Lucene documents populated
1) by numbers
2) by other strings
3) by values of another specific format
What kind of Analyzer would do it?
Using the customized analyzer, the current code is like
IndexWriter indexWriter = new IndexWriter(indexDir, analyzer, true);
Document doc = new Document();
doc.add(new Field("numeric_contents", new FileReader(f))); //
numeric tokens
doc.add(new Filed("other_contents", new FileReader(f))); //the
same file but other than numeric tokens
Thanks
--
Boris Galitsky.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: analyzer to populate more that one field of Lucene document
Posted by Boris Galitsky <bg...@rambler.ru>.
Thanks a lot Erick
Boris
* Erick Erickson <er...@gmail.com> [Thu, 21 Sep 2006 20:53:42
-0400]:
> I think you want a PerFieldAnalyzerWrapper. It allows you to make a
> different analyzer for each field in your document. You'll have to
write
> the
> code to extract the file contents in your desired formats for each
> field,
> but you probably do that already <G>...
>
> You can instantiate your IndexWriter with an instance of a
> PerFieldAnalyzerWrapper and it all "just happens" after that......
>
>
> >From the javadoc for PerFieldAnalyzerWrapper...
> <<< This analyzer is used to facilitate scenarios where different
fields
> require different analysis techniques.>>>
>
> Best
> Erick
>
> On 9/21/06, Boris Galitsky <bg...@rambler.ru> wrote:
> >
> > I need to create two fields for Lucene documents populated
> > 1) by numbers
> > 2) by other strings
> > 3) by values of another specific format
> >
> > What kind of Analyzer would do it?
> >
> > Using the customized analyzer, the current code is like
> >
> > IndexWriter indexWriter = new IndexWriter(indexDir, analyzer, true);
> > Document doc = new Document();
> > doc.add(new Field("numeric_contents", new FileReader(f))); //
> > numeric tokens
> > doc.add(new Filed("other_contents", new FileReader(f)));
> //the
> > same file but other than numeric tokens
> >
> > Thanks
> > --
> > Boris Galitsky.
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
--
Boris Galitsky.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: analyzer to populate more that one field of Lucene document
Posted by Erick Erickson <er...@gmail.com>.
I think you want a PerFieldAnalyzerWrapper. It allows you to make a
different analyzer for each field in your document. You'll have to write the
code to extract the file contents in your desired formats for each field,
but you probably do that already <G>...
You can instantiate your IndexWriter with an instance of a
PerFieldAnalyzerWrapper and it all "just happens" after that......
>From the javadoc for PerFieldAnalyzerWrapper...
<<< This analyzer is used to facilitate scenarios where different fields
require different analysis techniques.>>>
Best
Erick
On 9/21/06, Boris Galitsky <bg...@rambler.ru> wrote:
>
> I need to create two fields for Lucene documents populated
> 1) by numbers
> 2) by other strings
> 3) by values of another specific format
>
> What kind of Analyzer would do it?
>
> Using the customized analyzer, the current code is like
>
> IndexWriter indexWriter = new IndexWriter(indexDir, analyzer, true);
> Document doc = new Document();
> doc.add(new Field("numeric_contents", new FileReader(f))); //
> numeric tokens
> doc.add(new Filed("other_contents", new FileReader(f))); //the
> same file but other than numeric tokens
>
> Thanks
> --
> Boris Galitsky.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>