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 = searcher.search(query);


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 = searcher.search(query);

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

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

 Sergiu

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,

 Sergiu


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to