lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Sorokin" <alsor....@gmail.com>
Subject Re: how to craete index with particular ID
Date Thu, 01 Jun 2006 09:05:42 GMT
First of all you must understand that there is two stage: creating
index and searching by it.
I tell you olny how to create index.

To perform search you must do something like this:

IndexSearcher isearcher = new IndexSearcher(directory);
Query query = QueryParser.parse("text", "fieldname", analyzer);
Hits hits = isearcher.search(query);

"test" - is text of you query
"fieldname" - in you case is "TITLE"

of course if you don't going to search by "PATH" - you may not include
it in index.

I recommend tou consider this link:
http://lucene.apache.org/java/docs/api/overview-summary.html#overview_description

2006/6/1, Amaresh Kumar Yadav <Amaresh.Yadav@niit.com>:
> i want to search for text into "title" field only.
>
> how shuold i specify it?
>
> Regards..
> Amaresh
>
> -----Original Message-----
> From: Alexey Sorokin [mailto:alsor.net@gmail.com]
> Sent: Wednesday, May 31, 2006 4:21 PM
> To: java-user@lucene.apache.org
> Subject: Re: how to craete index with particular ID
>
>
> Actually you don't need to create text file. Get data from db and
> create Document that put in index. At least you must store ID of row
> in Document. Or you may store doctitle and docpath too.
>
> For each row you shoul do something like this:
>
> import org.apache.lucene.document.Document;
> import org.apache.lucene.document.Field;
>
> Document doc = new Document();
> doc.add(new Field("ID", [here you row ID value], Field.Store.YES,
> Field.Index.UN_TOKENIZED));
> doc.add(new Field("TITLE", [here value of doctitle field],
> Field.Store.NO, Field.Index.TOKENIZED));
> doc.add(new Field("PATH", [here value of docpath field],
> Field.Store.NO, Field.Index.TOKENIZED));
> indexWriter.addDocument(doc);
>
> After searcing you have Hits, get doc from Hits and get value of "ID"
> field of that doc - now you may get row from table by ID and receive
> any data.
>
> 2006/5/31, Amaresh Kumar Yadav <Amaresh.Yadav@niit.com>:
> > Hi All,
> >
> > Infact i want to search data which is stored  in a table on oracle...
> >
> > my table contains two fields "doctitle" and "docpath", first
> field(doctitle)
> > represents location of some document and second field(docpath)represents
> > documents title.
> >
> > I want to apply lucene search on doctitle.
> >
> > What i want to do for  search ...
> >
> > First create a text file which contains data(that is retrived by oracle
> > query) which is stored in table.
> >
> > Now i want to creat index for this file.
> >
> > now i want to search on title of document which is stored in the text
> file.
> >
> > after searching i want to disply corresponding path from index file.
> >
> > How should i creat such index file  ???
> >
> > how should i proceed????
> >
> >
> > With Thanks & Regards
> >
> > Amaresh
> >
> > ----------------------------------------------------------------------
> > DISCLAIMER
> >
> > This email and any files transmitted with it are confidential and are
> solely for the use of the individual or entity to which it is addressed. Any
> use, distribution, copying or disclosure by any other person is strictly
> prohibited. If you receive this transmission in error, please notify the
> sender by reply email and then destroy the message. Opinions, conclusions
> and other information in this message that do not relate to official
> business of the company shall be understood to be neither given nor endorsed
> by NIIT Ltd. or NIIT Technologies Ltd. Any information contained in this
> email, when addressed to Clients is subject to the terms and conditions in
> governing client contract.
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
>
>
> --
> ICQ: 166072598
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
> ----------------------------------------------------------------------
> DISCLAIMER
>
> This email and any files transmitted with it are confidential and are solely for the
use of the individual or entity to which it is addressed. Any use, distribution, copying or
disclosure by any other person is strictly prohibited. If you receive this transmission in
error, please notify the sender by reply email and then destroy the message. Opinions, conclusions
and other information in this message that do not relate to official business of the company
shall be understood to be neither given nor endorsed by NIIT Ltd. or NIIT Technologies Ltd.
Any information contained in this email, when addressed to Clients is subject to the terms
and conditions in governing client contract.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
ICQ: 166072598

---------------------------------------------------------------------
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