lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sergiu gordea <>
Subject Re: Searching for a path
Date Fri, 29 Oct 2004 06:25:57 GMT
Bill Tschumy wrote:

> I have a need to search an index for documents that were taken ffrom 
> particulars files in the filesystem.
> Each document in the index has a field named "url" that is created using:
>     doc.add(Field.Text("url", urlStr));
> I understand this is both stored and indexed.
> My search works if I do something like:
>     String queryStr = "\"file:///someDir/someOtherDir/File.txt\""
>      query = MultiFieldQueryParser.parse("url:" + queryString, 
> searchedFields, new StandardAnalyzer());
>      hits =;
> It is important for me to quote the path for the search to succeed
> I was hoping to speed the search up a bit by bypassing the 
> QueryParser.  However, if I do something like
>     String queryStr = "\"file:///someDir/someOtherDir/File.txt\""
>     Query query = new TermQuery(new Term("url", queryStr));
>     hits =;

For the begining I suggest you to make a system.out.println(query);

and to see what is the difference between the 2 queries ....


ahh.... I see now
you must to construct a PhraseQuery instead of TermQuery ...
The first one is PhraseQuery the second one that you construct with the 
term is TermQuery.
I suggest you to use QueryParser, the differemce in performance between 
your constructed query is just
the interpretation of regular expresion to find the type of the query. 
Using the QueryParser will ensure you that you won't
face problems that this one anymore.

    All the best,


> I get zero hits.  Why are these not equivalent?  I think it has 
> something to do with the fact that the url needs to be quoted so I 
> search for an exact match.  It does work if I have stored the url as a 
> "Field.Keyword" rather than as "Field.Text" and then don't need to 
> quote the string.  However I would prefer not to have to change the 
> format of the index.
> Thanks for any help.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message