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 Rob Outar <ro...@ideorlando.org> on 2002/10/23 23:47:34 UTC

Error when trying to match file path

Hi all,

I am indexing the filepath with the below:

 Document doc = new Document();
        doc.add(Field.UnIndexed("path", f.getAbsolutePath()));

I then try to run the following after building the index:

 this.query =
QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
        Hits hits = this.searcher.search(this.query);

It returns zero hits?!?

What am I doing wrong?

Any help would be appreciated.

Thanks,

Rob

RE: Error when trying to match file path

Posted by Rob Outar <ro...@ideorlando.org>.
Thanks for the reply, but I am already using a standard analyzer:

 Analyzer analyzer =new StandardAnalyzer();

The path is being stored as a string so I do not know why I cannot find a
match when I used the path as a query?  Do I need to phrase the query
differently?

QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);

Let me know.

Thanks,

Rob


-----Original Message-----
From: Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com]
Sent: Wednesday, October 23, 2002 5:54 PM
To: Lucene Users List
Subject: Re: Error when trying to match file path


http://www.jguru.com/faq/view.jsp?EID=538308

--- Rob Outar <ro...@ideorlando.org> wrote:
> Hi all,
>
> I am indexing the filepath with the below:
>
>  Document doc = new Document();
>         doc.add(Field.UnIndexed("path", f.getAbsolutePath()));
>
> I then try to run the following after building the index:
>
>  this.query =
> QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
>         Hits hits = this.searcher.search(this.query);
>
> It returns zero hits?!?
>
> What am I doing wrong?
>
> Any help would be appreciated.
>
> Thanks,
>
> Rob
>


__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Error when trying to match file path

Posted by Otis Gospodnetic <ot...@yahoo.com>.
http://www.jguru.com/faq/view.jsp?EID=538308

--- Rob Outar <ro...@ideorlando.org> wrote:
> Hi all,
> 
> I am indexing the filepath with the below:
> 
>  Document doc = new Document();
>         doc.add(Field.UnIndexed("path", f.getAbsolutePath()));
> 
> I then try to run the following after building the index:
> 
>  this.query =
> QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
>         Hits hits = this.searcher.search(this.query);
> 
> It returns zero hits?!?
> 
> What am I doing wrong?
> 
> Any help would be appreciated.
> 
> Thanks,
> 
> Rob
> 


__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Use filter instead of searching Re: Error when trying to match file path

Posted by Che Dong <ch...@hotmail.com>.
first indexing file path field with a untokened indexing field 
Field("filePath", file.getAbsolutePath(), true, true, false)

second , construct a prefix filter for searcher.I wrote a StringFilter.java for match and prefix match which can download from:
http://www.chedong.com/tech/lucene_ext.tar.gz

Che , Dong
----- Original Message ----- 
From: "Rob Outar" <ro...@ideorlando.org>
To: "Lucene Users List" <lu...@jakarta.apache.org>
Sent: Thursday, October 24, 2002 8:45 PM
Subject: RE: Error when trying to match file path


> Some more information, with the following:
> 
> this.query =
> QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
>         System.out.println(this.query.toString("path"));
> I got:
> F:"onesaf dev block b pair dev unittestdatafiles tools unitcomposer.xml"
> 
> So it looks like the Query Parser is stripping out all the "\", and doing
> something with the F:\, would anyone happen to know why this is happening?
> Do I need to use a different query to get the infromation I need?
> 
> Thanks,
> 
> Rob
> 
> -----Original Message-----
> From: Rob Outar [mailto:routar@ideorlando.org]
> Sent: Wednesday, October 23, 2002 5:48 PM
> To: lucene-user@jakarta.apache.org
> Subject: Error when trying to match file path
> 
> 
> Hi all,
> 
> I am indexing the filepath with the below:
> 
>  Document doc = new Document();
>         doc.add(Field.UnIndexed("path", f.getAbsolutePath()));
> 
> I then try to run the following after building the index:
> 
>  this.query =
> QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
>         Hits hits = this.searcher.search(this.query);
> 
> It returns zero hits?!?
> 
> What am I doing wrong?
> 
> Any help would be appreciated.
> 
> Thanks,
> 
> Rob
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>

RE: Error when trying to match file path

Posted by Rob Outar <ro...@ideorlando.org>.
I cannot get this to work for the life of me.  I am using a Standard
analyzer now.

Question 1:  What field type should the path be it be?
     doc.add(Field.UnIndexed("path", f.getAbsolutePath())); where f is a
file object

Question 2:  What should the query be to retieve that one file?

Term:

    Term t = new Term("path",file.getAbsolutePath());
		TermQuery tQ = new TermQuery(t);
        System.out.println(tQ.toString("path"));
        Hits hits = this.searcher.search(tQ);
        System.out.println(hits.length() + " total matching documents");
or:

	/*	QueryParser parser = new QueryParser();
        System.out.println(file.getAbsolutePath());
		this.query = parser.parse(file.getAbsolutePath());
        System.out.println(this.query.toString("path"));
        Hits hits = this.searcher.search(this.query);
        System.out.println(hits.length() + " total matching documents");
        Document doc = hits.doc(0);
        System.out.println("class = " + doc.get("classification"));*/

If I can get past this hurdle I will so be on my way.


Thanks,

Rob


-----Original Message-----
From: Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com]
Sent: Thursday, October 24, 2002 10:37 AM
To: Lucene Users List
Subject: RE: Error when trying to match file path


The Analyzer is stripping your \ characters.  Query Parser doesn't do
that...

Otis

--- Rob Outar <ro...@ideorlando.org> wrote:
> Some more information, with the following:
>
> 		this.query =
> QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
>         System.out.println(this.query.toString("path"));
> I got:
> F:"onesaf dev block b pair dev unittestdatafiles tools
> unitcomposer.xml"
>
> So it looks like the Query Parser is stripping out all the "\", and
> doing
> something with the F:\, would anyone happen to know why this is
> happening?
> Do I need to use a different query to get the infromation I need?
>
> Thanks,
>
> Rob
>
> -----Original Message-----
> From: Rob Outar [mailto:routar@ideorlando.org]
> Sent: Wednesday, October 23, 2002 5:48 PM
> To: lucene-user@jakarta.apache.org
> Subject: Error when trying to match file path
>
>
> Hi all,
>
> I am indexing the filepath with the below:
>
>  Document doc = new Document();
>         doc.add(Field.UnIndexed("path", f.getAbsolutePath()));
>
> I then try to run the following after building the index:
>
>  this.query =
> QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
>         Hits hits = this.searcher.search(this.query);
>
> It returns zero hits?!?
>
> What am I doing wrong?
>
> Any help would be appreciated.
>
> Thanks,
>
> Rob
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>


__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Setting fields

Posted by Otis Gospodnetic <ot...@yahoo.com>.
http://www.jguru.com/faq/view.jsp?EID=938300

--- Rob Outar <ro...@ideorlando.org> wrote:
> Hello,
> 
> 	Is there is way to set a field once it has been associated with a
> document?
> For example if I have a field named filename, and the file is renamed
> I now
> need to update the field filename with the new name of the file.  I
> did not
> see any setter methods on Field.  The only solution that comes to
> mind is to
> fetch the document based on it's URL, remove it from the index, then
> read it
> with the new value.
> 
> Let me know,
> 
> Thanks,
> 
> Rob
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Setting fields

Posted by Rob Outar <ro...@ideorlando.org>.
Hello,

	Is there is way to set a field once it has been associated with a document?
For example if I have a field named filename, and the file is renamed I now
need to update the field filename with the new name of the file.  I did not
see any setter methods on Field.  The only solution that comes to mind is to
fetch the document based on it's URL, remove it from the index, then read it
with the new value.

Let me know,

Thanks,

Rob


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Error when trying to match file path

Posted by Rob Outar <ro...@ideorlando.org>.
I finally got it to work, but I do not understand the solution, instead of
storing the file path (F:\blah\blah\blah.xml), I stored the URL of file in
the field called path, I was then able to use a TermQuery(path, URL) to
retrieve that one document from the index.

Thanks,

Rob


-----Original Message-----
From: Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com]
Sent: Thursday, October 24, 2002 10:37 AM
To: Lucene Users List
Subject: RE: Error when trying to match file path


The Analyzer is stripping your \ characters.  Query Parser doesn't do
that...

Otis

--- Rob Outar <ro...@ideorlando.org> wrote:
> Some more information, with the following:
>
> 		this.query =
> QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
>         System.out.println(this.query.toString("path"));
> I got:
> F:"onesaf dev block b pair dev unittestdatafiles tools
> unitcomposer.xml"
>
> So it looks like the Query Parser is stripping out all the "\", and
> doing
> something with the F:\, would anyone happen to know why this is
> happening?
> Do I need to use a different query to get the infromation I need?
>
> Thanks,
>
> Rob
>
> -----Original Message-----
> From: Rob Outar [mailto:routar@ideorlando.org]
> Sent: Wednesday, October 23, 2002 5:48 PM
> To: lucene-user@jakarta.apache.org
> Subject: Error when trying to match file path
>
>
> Hi all,
>
> I am indexing the filepath with the below:
>
>  Document doc = new Document();
>         doc.add(Field.UnIndexed("path", f.getAbsolutePath()));
>
> I then try to run the following after building the index:
>
>  this.query =
> QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
>         Hits hits = this.searcher.search(this.query);
>
> It returns zero hits?!?
>
> What am I doing wrong?
>
> Any help would be appreciated.
>
> Thanks,
>
> Rob
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>


__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Error when trying to match file path

Posted by Otis Gospodnetic <ot...@yahoo.com>.
The Analyzer is stripping your \ characters.  Query Parser doesn't do
that...

Otis

--- Rob Outar <ro...@ideorlando.org> wrote:
> Some more information, with the following:
> 
> 		this.query =
> QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
>         System.out.println(this.query.toString("path"));
> I got:
> F:"onesaf dev block b pair dev unittestdatafiles tools
> unitcomposer.xml"
> 
> So it looks like the Query Parser is stripping out all the "\", and
> doing
> something with the F:\, would anyone happen to know why this is
> happening?
> Do I need to use a different query to get the infromation I need?
> 
> Thanks,
> 
> Rob
> 
> -----Original Message-----
> From: Rob Outar [mailto:routar@ideorlando.org]
> Sent: Wednesday, October 23, 2002 5:48 PM
> To: lucene-user@jakarta.apache.org
> Subject: Error when trying to match file path
> 
> 
> Hi all,
> 
> I am indexing the filepath with the below:
> 
>  Document doc = new Document();
>         doc.add(Field.UnIndexed("path", f.getAbsolutePath()));
> 
> I then try to run the following after building the index:
> 
>  this.query =
> QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
>         Hits hits = this.searcher.search(this.query);
> 
> It returns zero hits?!?
> 
> What am I doing wrong?
> 
> Any help would be appreciated.
> 
> Thanks,
> 
> Rob
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Error when trying to match file path

Posted by Rob Outar <ro...@ideorlando.org>.
Some more information, with the following:

		this.query =
QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
        System.out.println(this.query.toString("path"));
I got:
F:"onesaf dev block b pair dev unittestdatafiles tools unitcomposer.xml"

So it looks like the Query Parser is stripping out all the "\", and doing
something with the F:\, would anyone happen to know why this is happening?
Do I need to use a different query to get the infromation I need?

Thanks,

Rob

-----Original Message-----
From: Rob Outar [mailto:routar@ideorlando.org]
Sent: Wednesday, October 23, 2002 5:48 PM
To: lucene-user@jakarta.apache.org
Subject: Error when trying to match file path


Hi all,

I am indexing the filepath with the below:

 Document doc = new Document();
        doc.add(Field.UnIndexed("path", f.getAbsolutePath()));

I then try to run the following after building the index:

 this.query =
QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
        Hits hits = this.searcher.search(this.query);

It returns zero hits?!?

What am I doing wrong?

Any help would be appreciated.

Thanks,

Rob


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Error when trying to match file path

Posted by Matthew King <ma...@gnik.com>.
Instead of UnIndexed, have you tried using a Keyword field?

 From the javadoc:
   Field.UnIndexed:  Constructs a String-valued Field that is
                     not tokenized nor indexed, but is stored
                     in the index, for return with hits.

   Field.Keyword:    Constructs a String-valued Field that is
                     not tokenized, but is indexed and stored.

(note that I haven't tried this in code with file paths, so there may 
still be analyzer tweaking necessary)

- matt

On Wednesday, October 23, 2002, at 05:47  PM, Rob Outar wrote:

> Hi all,
>
> I am indexing the filepath with the below:
>
>  Document doc = new Document();
>         doc.add(Field.UnIndexed("path", f.getAbsolutePath()));
>
> I then try to run the following after building the index:
>
>  this.query =
> QueryParser.parse(file.getAbsolutePath(),"path",this.analyzer);
>         Hits hits = this.searcher.search(this.query);
>
> It returns zero hits?!?
>
> What am I doing wrong?
>
> Any help would be appreciated.
>
> Thanks,
>
> Rob


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>