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 oh...@cox.net on 2009/07/30 15:40:42 UTC

How to search "path"?

Hi,

I am working with a modified version of the demo IndexFiles.

In that code, when it builds the index, it has:

    doc.add(new Field("path", f.getPath(), Field.Store.YES, Field.Index.NOT_ANALYZED));

In Luke, I can see all the file paths in the "path" field.

I am also using the demo luceneweb web app (under Tomcat), and I've been trying to search on the "path" field.

For example, if the "path" has something like:

C:\lucene\foo\myfile1.dat

Is there a way to search for the "myfile1"?

I tried something like:

*myfile1*

but I get an error, because it apparently doesn't like the "*" at the beginning of the query string.

Thanks,
Jim

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


Re: How to search "path"?

Posted by oh...@cox.net.
Ian,

I'll respond to this msg, re. searching "path".

I made the change you suggested, to "Field.Index.ANALYZED", and that fixed the problem I was having with searching for components of the "path" field.

Thanks!

Jim

---- Ian Lea <ia...@gmail.com> wrote: 
> In contrast to your last question and reply, if you use
> 
>    doc.add(new Field("path", f.getPath(), Field.Store.YES,
> Field.Index.ANALYZED));
> 
> the path will get split into tokens which will include "myfile1" and
> you will be able to search for it.
> 
> The key concept for both questions is analysis.  Lucene provides
> various analyzers which do different things, and you can write your
> own.
> 
> 
> Or, call QueryParser.setAllowLeadingWildcard(true).  That has
> performance implications on large indexes.
> 
> 
> --
> Ian.
> 
> On Thu, Jul 30, 2009 at 2:40 PM, <oh...@cox.net> wrote:
> > Hi,
> >
> > I am working with a modified version of the demo IndexFiles.
> >
> > In that code, when it builds the index, it has:
> >
> >    doc.add(new Field("path", f.getPath(), Field.Store.YES, Field.Index.NOT_ANALYZED));
> >
> > In Luke, I can see all the file paths in the "path" field.
> >
> > I am also using the demo luceneweb web app (under Tomcat), and I've been trying to search on the "path" field.
> >
> > For example, if the "path" has something like:
> >
> > C:\lucene\foo\myfile1.dat
> >
> > Is there a way to search for the "myfile1"?
> >
> > I tried something like:
> >
> > *myfile1*
> >
> > but I get an error, because it apparently doesn't like the "*" at the beginning of the query string.
> >
> > Thanks,
> > Jim
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 


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


Re: How to search "path"?

Posted by Ian Lea <ia...@gmail.com>.
In contrast to your last question and reply, if you use

   doc.add(new Field("path", f.getPath(), Field.Store.YES,
Field.Index.ANALYZED));

the path will get split into tokens which will include "myfile1" and
you will be able to search for it.

The key concept for both questions is analysis.  Lucene provides
various analyzers which do different things, and you can write your
own.


Or, call QueryParser.setAllowLeadingWildcard(true).  That has
performance implications on large indexes.


--
Ian.

On Thu, Jul 30, 2009 at 2:40 PM, <oh...@cox.net> wrote:
> Hi,
>
> I am working with a modified version of the demo IndexFiles.
>
> In that code, when it builds the index, it has:
>
>    doc.add(new Field("path", f.getPath(), Field.Store.YES, Field.Index.NOT_ANALYZED));
>
> In Luke, I can see all the file paths in the "path" field.
>
> I am also using the demo luceneweb web app (under Tomcat), and I've been trying to search on the "path" field.
>
> For example, if the "path" has something like:
>
> C:\lucene\foo\myfile1.dat
>
> Is there a way to search for the "myfile1"?
>
> I tried something like:
>
> *myfile1*
>
> but I get an error, because it apparently doesn't like the "*" at the beginning of the query string.
>
> Thanks,
> Jim
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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