Mailing List Archive

excluding directories and using lucene in servlets
I have a really simple servlet example already created that appears to work.
I adopted most of the code from the .jsp example posted earlier from
Douglass Cutting. However, I have two questions:

First, (this is related more to the servlet aspect) in the .jsp file there
are a couple of lines of code that deal with the 'application' variable:

i.e. indexPath = application.getRealPath( "/" + index );

apparently I need this code in order to create the index sercher by giving
it the physical path to the index that I'm going to use. I need to
reproduce the application variable inside the servlet. I'm using a (really
bad!) work around currently that uses a hidden field in the query form page
to store the index path (using the application variable). I have found that
the application variable is related to the servletContext property of the
HTTPServlet class. Does anyone have an idea of how to instantiate this
inside a servlet? Any information related to struts would be of assistance
as well as the perform method only gives you access to the request and
response objects.

Second, is there anyway to exclude directories from being indexed?

For example, I need an index of everything in the /doc directory but not
items in /doc/restricted directory.

I'm thinking that you should be able to do this at creation time, or
removing them after, but perhaps I could settle with creating the query and
removing items that are located in that directory. Does anyone have any
suggestions on how to accomplish this?

Once I get my app running correctly, I'll post the code that I used in my
servlet example.

Thanks.



--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: excluding directories and using lucene in servlets [ In reply to ]
Could you send a pointer to the jsp example that Doug posted? I'm looking
at developing jsp's with lucene, and Doug's input would be invaluable.]

Rob
----- Original Message -----
From: "Brian Rook" <brian.rook@xor.com>
To: <lucene-user@jakarta.apache.org>
Sent: Wednesday, January 16, 2002 11:35 AM
Subject: excluding directories and using lucene in servlets


> I have a really simple servlet example already created that appears to
work.
> I adopted most of the code from the .jsp example posted earlier from
> Douglass Cutting. However, I have two questions:
>
> First, (this is related more to the servlet aspect) in the .jsp file there
> are a couple of lines of code that deal with the 'application' variable:
>
> i.e. indexPath = application.getRealPath( "/" + index );
>
> apparently I need this code in order to create the index sercher by giving
> it the physical path to the index that I'm going to use. I need to
> reproduce the application variable inside the servlet. I'm using a
(really
> bad!) work around currently that uses a hidden field in the query form
page
> to store the index path (using the application variable). I have found
that
> the application variable is related to the servletContext property of the
> HTTPServlet class. Does anyone have an idea of how to instantiate this
> inside a servlet? Any information related to struts would be of
assistance
> as well as the perform method only gives you access to the request and
> response objects.
>
> Second, is there anyway to exclude directories from being indexed?
>
> For example, I need an index of everything in the /doc directory but not
> items in /doc/restricted directory.
>
> I'm thinking that you should be able to do this at creation time, or
> removing them after, but perhaps I could settle with creating the query
and
> removing items that are located in that directory. Does anyone have any
> suggestions on how to accomplish this?
>
> Once I get my app running correctly, I'll post the code that I used in my
> servlet example.
>
> Thanks.
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:lucene-user-help@jakarta.apache.org>


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: excluding directories and using lucene in servlets [ In reply to ]
Hi Brian,

Your first question is better suited for the Tomcat or Struts list, but
the answer is you can use the
There is a getServletConfig() method inherited for all servlets which
returns a ServletConfig.
Then you can call, getRealPath from that.
The servlet engine may already provide the ServletConfig into a variable
like application in jsps.

For your second question, you can easily edit the Document class you are
using.
If you are using one of the demo Document classes, you can just edit the
indexDocs() method to filter as desired.

Good luck

--Peter


On Wednesday, January 16, 2002, at 09:35 AM, Brian Rook wrote:

> I have a really simple servlet example already created that appears to
> work.
> I adopted most of the code from the .jsp example posted earlier from
> Douglass Cutting. However, I have two questions:
>
> First, (this is related more to the servlet aspect) in the .jsp file
> there
> are a couple of lines of code that deal with the 'application' variable:
>
> i.e. indexPath = application.getRealPath( "/" + index );
>
> apparently I need this code in order to create the index sercher by
> giving
> it the physical path to the index that I'm going to use. I need to
> reproduce the application variable inside the servlet. I'm using a
> (really
> bad!) work around currently that uses a hidden field in the query form
> page
> to store the index path (using the application variable). I have found
> that
> the application variable is related to the servletContext property of
> the
> HTTPServlet class. Does anyone have an idea of how to instantiate this
> inside a servlet? Any information related to struts would be of
> assistance
> as well as the perform method only gives you access to the request and
> response objects.
>
> Second, is there anyway to exclude directories from being indexed?
>
> For example, I need an index of everything in the /doc directory but not
> items in /doc/restricted directory.
>
> I'm thinking that you should be able to do this at creation time, or
> removing them after, but perhaps I could settle with creating the query
> and
> removing items that are located in that directory. Does anyone have any
> suggestions on how to accomplish this?
>
> Once I get my app running correctly, I'll post the code that I used in
> my
> servlet example.
>
> Thanks.
>
>
>
> --
> To unsubscribe, e-mail: <mailto:lucene-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:lucene-user-
> help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>