lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sujit Pal <sujit....@comcast.net>
Subject Re: How can i index a Java Bean into Lucene application ?
Date Sun, 07 Aug 2011 20:04:52 GMT
Depending on what you wanted to do with the Javabean (I assume you want
to make some or all its fields searchable since you are writing to
Lucene), you could use reflection to break it up into field name value
pairs and write them out to the IndexWriter using something like this:

Document d = new Document();
d.addField(fieldname1, fieldvalue1, Store.YES, Index.ANALYZED, ...)
...
writer.addDocument(d);

-sujit

On Sat, 2011-08-06 at 18:28 +0530, KARTHIK SHIVAKUMAR wrote:
> Hi
> 
> How can i  index a  Java Bean  into Lucene  application ?  instead of a
> file
> 
> API  : IndexWriter writer = new IndexWriter(*FSDirectory.open(INDEX_DIR)*,
> new StandardAnalyzer(Version.LUCENE_CURRENT), true,
> IndexWriter.MaxFieldLength.LIMITED);
> 
> Is there any alternate for the same .
> 
> ex:
> 
> * package com.web.beans.searchdata;*
> 
> * public class SearchIndexHtmlData {
> 
>     public String CONTENT             ="NA";
>     public String DATEOFCREATION      ="NA";
>     public String DATEOFINDEXCREATION ="NA";
> 
> 
>     public String getCONTENT() {
>         return CONTENT;
>     }
>     public void setCONTENT(String cONTENT) {
>         CONTENT = cONTENT;
>     }
>     public String getDATEOFCREATION() {
>         return DATEOFCREATION;
>     }
>     public void setDATEOFCREATION(String dATEOFCREATION) {
>         DATEOFCREATION = dATEOFCREATION;
>     }
>     public String getDATEOFINDEXCREATION() {
>         return DATEOFINDEXCREATION;
>     }
>     public void setDATEOFINDEXCREATION(String dATEOFINDEXCREATION) {
>         DATEOFINDEXCREATION = dATEOFINDEXCREATION;
>     }
> }*
> 
> 


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


Mime
View raw message