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 fmarchioni <fm...@libero.it> on 2003/07/10 12:03:43 UTC
Can I do this with Lucene ?
Dear Lucene Users,
I'd like to implement a search engine and I'd like to know if it's possible to
do it with Lucene.
I have many text files containing faqs, every faq has a text file.
Inside the file questions are listed with a delimiter (I use # but it can by any)
#Question1
bla bla bla bla
#Question2
bla bla bla bla
...and so on....
Now I'd like something that search for words inside the faqs and RETURNS THE BLOCK
where it was found (#Question1 bla bla bla bla)....in other words I want to retrieve
a single faq using a search engine.
I didn't see anything like this in the docs....just something that return the number of hits
of a search.....can Lucene do it for me easily or it's better to write it on my own using
standard Java I/O Api ?
Thanks a lot
Francesco
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: Can I do this with Lucene ?
Posted by Eric Jain <Er...@isb-sib.ch>.
> I want to retrieve
> a single faq using a search engine.
You could index FAQs instead of files.
for file in listFiles():
for faq in extractFaqs(file):
doc = Document()
doc.add(Field.Keyword('key', faq.id))
doc.add(Field.Keyword('file', file))
doc.add(Field.Unstored('content', faq.content))
writer.addDocument(doc)
> I didn't see anything like this in the docs....just something that
> return the number of hits of a search
One solution would be to create a custom HitCollector that simply counts
hits and then 'searcher.search(query, hitCollector)'.
--
Eric Jain
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: Can I do this with Lucene ?
Posted by Morus Walter <mo...@tanto-xipolis.de>.
Hi Francesco,
> I'd like to implement a search engine and I'd like to know if it's possible to
> do it with Lucene.
> I have many text files containing faqs, every faq has a text file.
> Inside the file questions are listed with a delimiter (I use # but it can by any)
>
> #Question1
> bla bla bla bla
>
> #Question2
> bla bla bla bla
>
> ...and so on....
>
> Now I'd like something that search for words inside the faqs and RETURNS THE BLOCK
> where it was found (#Question1 bla bla bla bla)....in other words I want to retrieve
> a single faq using a search engine.
>
> I didn't see anything like this in the docs....just something that return the number of hits
> of a search.....can Lucene do it for me easily or it's better to write it on my own using
> standard Java I/O Api ?
Well lucene indexes units of text as you provide them.
So if you make each question a document in lucenes sense you will get
the question and any info you stored with it (eg. faq-file and question
number).
Seems straight forward to me.
There is no need that files and documents in lucene have a 1:1 relation.
HTH
Morus
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org