Hi Dinesh,

This seems straightforward for Solr. You can use the embedded jetty server
for a start. Look at the tutorial on how to get started.

You'll need to modify the schema.xml to define all the fields that you want
to index. The wiki page at http://wiki.apache.org/solr/SchemaXml is a good
start on how to do that. Each field in your code will have a counterpart in
the schema.xml with appropriate flags (indexed/stored/tokenized etc.)

Once that is complete, try to modify the DataImportHandler's hsqldb example
for your mysql database.

On Tue, Sep 23, 2008 at 7:01 PM, Dinesh Gupta <[EMAIL PROTECTED]>wrote:

>
> Hi Shalin Shekhar,
>
> Let me explain my issue.
>
> I have some tables in my database like
>
> Product
> Category
> Catalogue
> Keywords
> Seller
> Brand
> Country_city_group
> etc.
> I have a class that represent  product document as
>
> Document doc = new Document();
>        // Keywords which can be used directly for search
>        doc.add(new Field("id",(String)
> data.get("PRN"),Field.Store.YES,Field.Index.UN_TOKENIZED));
>
>        // Sorting fields]
>        String priceString = (String) data.get("Price");
>        if (priceString == null)
>            priceString = "0";
>        long price = 0;
>        try {
>            price = (long) Double.parseDouble(priceString);
>        } catch (Exception e) {
>
>        }
>
>        doc.add(new
> Field("prc",NumberUtils.pad(price),Field.Store.YES,Field.Index.UN_TOKENIZED));
>        Date createDate = (Date) data.get("CreateDate");
>        if (createDate == null) createDate = new Date();
>
>        doc.add(new Field("cdt",String.valueOf(createDate.getTime()),
> Field.Store.NO,Field.Index.UN_TOKENIZED));
>
>        Date modiDate = (Date) data.get("ModiDate");
>        if (modiDate == null) modiDate = new Date();
>
>        doc.add(new Field("mdt",String.valueOf(modiDate.getTime()),
> Field.Store.NO,Field.Index.UN_TOKENIZED));
>        //doc.add(Field.UnStored("cdt",
> String.valueOf(createDate.getTime())));
>
>        // Additional fields for search
>        doc.add(new Field("bnm",(String)
> data.get("Brand"),Field.Store.YES,Field.Index.TOKENIZED));
>        doc.add(new Field("bnm1",(String) data.get("Brand1"),Field.Store.NO
> ,Field.Index.UN_TOKENIZED));
>        //doc.add(Field.Text("bnm", (String) data.get("Brand")));
> //Tokenized and Unstored
>        doc.add(new Field("bid",(String)
> data.get("BrandId"),Field.Store.YES,Field.Index.UN_TOKENIZED));
>        //doc.add(Field.Keyword("bid", (String) data.get("BrandId"))); //
> untokenized &
>        doc.add(new Field("grp",(String) data.get("Group"),Field.Store.NO
> ,Field.Index.TOKENIZED));
>        //doc.add(Field.Text("grp", (String) data.get("Group")));
>        doc.add(new Field("gid",(String)
> data.get("GroupId"),Field.Store.YES,Field.Index.UN_TOKENIZED));
>        //doc.add(Field.Keyword("gid", (String) data.get("GroupId"))); //New
>        doc.add(new Field("snm",(String)
> data.get("Seller"),Field.Store.YES,Field.Index.UN_TOKENIZED));
>        //doc.add(Field.Text("snm", (String) data.get("Seller")));
>        doc.add(new Field("sid",(String)
> data.get("SellerId"),Field.Store.YES,Field.Index.UN_TOKENIZED));
>        //doc.add(Field.Keyword("sid", (String) data.get("SellerId"))); //
> New
>        doc.add(new Field("ttl",(String)
> data.get("Title"),Field.Store.YES,Field.Index.TOKENIZED));
>        //doc.add(Field.UnStored("ttl", (String) data.get("Title"), true));
>
>        String title1 = (String) data.get("Title");
>        title1 = removeSpaces(title1);
>        doc.add(new Field("ttl1",title1,Field.Store.NO
> ,Field.Index.UN_TOKENIZED));
>
>        doc.add(new Field("ttl2",title1,Field.Store.NO
> ,Field.Index.TOKENIZED));
>        //doc.add(Field.UnStored("ttl", (String) data.get("Title"), true));
>
>        // ColumnC - Product Sequence
>        String productSeq = (String) data.get("ProductSeq");
>        if (productSeq == null) productSeq = "";
>        doc.add(new Field("seq",productSeq,Field.Store.NO
> ,Field.Index.UN_TOKENIZED));
>        //doc.add(Field.Keyword("seq", productSeq));
>
>        // New Added
>        doc.add(new Field("sdc",(String) data.get("SpecialDescription"),
> Field.Store.NO,Field.Index.TOKENIZED));
>        //doc.add(Field.UnStored("sdc", (String)
> data.get("SpecialDescription"),true));
>        doc.add(new Field("kdc", (String) data.get("KeywordDescription"),
> Field.Store.NO,Field.Index.TOKENIZED));
>        //doc.add(Field.UnStored("kdc", (String)
> data.get("KeywordDescription"),true));
>
>        // ColumnB - Product Category and parent categories
>        doc.add(new Field("cts",(String)
> data.get("Categories"),Field.Store.YES,Field.Index.TOKENIZED));
>        //doc.add(Field.Text("cts", (String) data.get("Categories")));
>
>        // ColumnB - Product Category and parent categories //Raman
>        doc.add(new Field("dct",(String)
> data.get("DirectCategories"),Field.Store.YES,Field.Index.TOKENIZED));
>        //doc.add(Field.Text("dct", (String) data.get("DirectCategories")));
>
>        // ColumnC - Product Catalogues
>        doc.add(new Field("clg",(String)
> data.get("Catalogues"),Field.Store.YES,Field.Index.TOKENIZED));
>        //doc.add(Field.Text("clg", (String) data.get("Catalogues")));
>
>        //Product Delivery Cities
>        doc.add(new Field("dcty",(String)
> data.get("DelCities"),Field.Store.YES,Field.Index.TOKENIZED));
>        // Additional Information
>        //Top Selling Count
>        String sellerCount=((Long)data.get("SellCount")).toString();
>        doc.add(new
> Field("bsc",sellerCount,Field.Store.YES,Field.Index.TOKENIZED));
>
>
>    I am preparing data from querying databse.
> Please tell me how can I migrate my logic to Solr.
> I have spend more than a week.
> But have got nothing.
> Please help me.
>
> Can I attach my files here?
>
> Thanks in Advance
>
> Regards
> Dinesh Gupta
>
> > Date: Tue, 23 Sep 2008 18:53:07 +0530
> > From: [EMAIL PROTECTED]
> > To: solr-user@lucene.apache.org
> > Subject: Re: Lucene index
> >
> > On Tue, Sep 23, 2008 at 5:33 PM, Dinesh Gupta <
> [EMAIL PROTECTED]>wrote:
> >
> > >
> > > Hi,
> > > Current we are using Lucene api to create index.
> > >
> > > It creates index in a directory with 3 files like
> > >
> > > xxx.cfs , deletable & segments.
> > >
> > > If I am creating Lucene indexes from Solr, these file will be created
> or
> > > not?
> >
> >
> > The lucene index will be created in the solr_home inside the data/index
> > directory.
> >
> >
> > > Please give me example on MySQL data base instead of hsqldb
> > >
> >
> > If you are talking about DataImportHandler then there is no difference in
> > the configuration except for using the MySql driver instead of hsqldb.
> >
> > --
> > Regards,
> > Shalin Shekhar Mangar.
>
> _________________________________________________________________
> Want to explore the world? Visit MSN Travel for the best deals.
> http://in.msn.com/coxandkings
>



-- 
Regards,
Shalin Shekhar Mangar.

Reply via email to