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 KARTHIK SHIVAKUMAR <ns...@gmail.com> on 2011/08/06 14:58:49 UTC

How can i index a Java Bean into Lucene application ?

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;
    }
}*


-- 
*N.S.KARTHIK
R.M.S.COLONY
BEHIND BANK OF INDIA
R.M.V 2ND STAGE
BANGALORE
560094*

Re: How can i index a Java Bean into Lucene application ?

Posted by Sujit Pal <su...@comcast.net>.
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