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 Aslam Bari <ia...@yahoo.co.in> on 2007/01/05 13:07:48 UTC

Lucene search returns Zip file Name

Dear all,
I m using lucene to index zip files. Suppose a zip file contains 4 files.
All files get indexed well with uri of Zip file means when i search for any
content the result comes and the resutl file name is zip file, but i need to
know the real file name in which the data found. How to get that file
name???
Thanks....
-- 
View this message in context: http://www.nabble.com/Lucene-search-returns-Zip-file-Name-tf2925197.html#a8176954
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: Lucene search returns Zip file Name

Posted by Erick Erickson <er...@gmail.com>.
This is a confusing question. You have to create the index in the first
place. You can't just give the zip file to Lucene and expect it to do all
your work for you.

Somewhere, you have to have code like

Document doc = new Document();
doc.add(new Field("fieldname1", "stuff to store", Field.Store.***,
Field.Index.***));
doc.add(new Field("fieldname2", "more stuff to store", Field.Store.***,
Field.Index.***));
.
.
.
writer.add(doc);

the stuff you store in, say, fieldname1 is whatever you want. In this case,
say the real file name.
the stuff you store in, say, fieldname2 could be the zip file name.
the stuff you store in, say, fieldname3 could be the text of the file you
got from the zip file corresponding to fieldname1.

If this is conceptually unclear, I strongly recommend that you get a copy of
"Lucene in Action". It's has many examples of how to use lucene. Note that
it is written to the 1.4 code base, so there are some minor differences
between it and the latest 2.0 code.

Lucene isn't magic. It's an indexing and searching toolbox with an API that
you have to program with.

Best
Erick

On 1/5/07, Aslam Bari <ia...@yahoo.co.in> wrote:
>
>
> Hi Erick,
> Thanks for reply,
> Can you tell me how to change indexer to store custom fields so that i can
> store two new fields like "Main File Name" and "Real File Name". so i can
> store Zip File name as Main file and Actual file where data found in Real
> File.
>
> Thanks...
>
>
> Erick Erickson wrote:
> >
> > You only get things out of an index that you put in there. At index
> time,
> > you need to associate file names with content. Something like indexing
> the
> > text of each file in the zip file as a separate lucene document, perhaps
> > with the associated zip file name and the real file name.
> >
> > Best
> > Erick
> >
> >
> > On 1/5/07, Aslam Bari <ia...@yahoo.co.in> wrote:
> >>
> >>
> >> Dear all,
> >> I m using lucene to index zip files. Suppose a zip file contains 4
> files.
> >> All files get indexed well with uri of Zip file means when i search for
> >> any
> >> content the result comes and the resutl file name is zip file, but i
> need
> >> to
> >> know the real file name in which the data found. How to get that file
> >> name???
> >> Thanks....
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Lucene-search-returns-Zip-file-Name-tf2925197.html#a8176954
> >> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >> For additional commands, e-mail: java-user-help@lucene.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Lucene-search-returns-Zip-file-Name-tf2925197.html#a8190488
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Lucene search returns Zip file Name

Posted by Aslam Bari <ia...@yahoo.co.in>.
Hi Erick,
Thanks for reply,
Can you tell me how to change indexer to store custom fields so that i can
store two new fields like "Main File Name" and "Real File Name". so i can
store Zip File name as Main file and Actual file where data found in Real
File.

Thanks...


Erick Erickson wrote:
> 
> You only get things out of an index that you put in there. At index time,
> you need to associate file names with content. Something like indexing the
> text of each file in the zip file as a separate lucene document, perhaps
> with the associated zip file name and the real file name.
> 
> Best
> Erick
> 
> 
> On 1/5/07, Aslam Bari <ia...@yahoo.co.in> wrote:
>>
>>
>> Dear all,
>> I m using lucene to index zip files. Suppose a zip file contains 4 files.
>> All files get indexed well with uri of Zip file means when i search for
>> any
>> content the result comes and the resutl file name is zip file, but i need
>> to
>> know the real file name in which the data found. How to get that file
>> name???
>> Thanks....
>> --
>> View this message in context:
>> http://www.nabble.com/Lucene-search-returns-Zip-file-Name-tf2925197.html#a8176954
>> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Lucene-search-returns-Zip-file-Name-tf2925197.html#a8190488
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: Lucene search returns Zip file Name

Posted by Erick Erickson <er...@gmail.com>.
You only get things out of an index that you put in there. At index time,
you need to associate file names with content. Something like indexing the
text of each file in the zip file as a separate lucene document, perhaps
with the associated zip file name and the real file name.

Best
Erick


On 1/5/07, Aslam Bari <ia...@yahoo.co.in> wrote:
>
>
> Dear all,
> I m using lucene to index zip files. Suppose a zip file contains 4 files.
> All files get indexed well with uri of Zip file means when i search for
> any
> content the result comes and the resutl file name is zip file, but i need
> to
> know the real file name in which the data found. How to get that file
> name???
> Thanks....
> --
> View this message in context:
> http://www.nabble.com/Lucene-search-returns-Zip-file-Name-tf2925197.html#a8176954
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>