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 Ruud Dozijn <rd...@hotmail.com> on 2013/09/24 12:58:33 UTC

checking index for existance of paths

hi all,

I
 am quite new to Lucene. I have downloaded an example from a tutorial, 
adapted it for version 3.6 (which is the one I have installed) and run 
it several times.

The script indexes an array of files and adds 
them to the Lucene index. Then, the user can query the documentset by 
keying in queries.

If a file is added two times, it appears two 
time in the query results. I want to change this behaviour by first 
testing if a file is in the index already, and skipping the add if this 
is the case.

When a file is added to the index, the following code is executed:

    doc.add(new Field("contents", tekst , Field.Store.YES, Field.Index.ANALYZED));
    doc.add(new Field("path", f.getPath(), Field.Store.YES, Field.Index.NOT_ANALYZED));
    doc.add(new Field("filename", f.getName(), Field.Store.YES, Field.Index.NOT_ANALYZED));

If I want to check a certain file with for example query 'filename:/tmp/test/t1.txt', I get no results, because the slashes are converted to spaces when doing an exact match, or the query is split up into 'filename:tmp' , 'filename:test' and 'filename:t1.txt'. Which is _not_ what I want. 

What can I do to check for a complete file path?

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


RE: checking index for existance of paths

Posted by Ruud Dozijn <rd...@hotmail.com>.
----------------------------------------

>>
>> What can I do to check for a complete file path?
>
> Do not use the QueryParser.
> You do not want an Analyzer, so just create a TermQuery directly.

Thanks for the advice, this was the missing jigsaw piece, 
Ruud 		 	   		  
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: checking index for existance of paths

Posted by Roberto Ragusa <ma...@robertoragusa.it>.
On 09/24/2013 12:58 PM, Ruud Dozijn wrote:
> If I want to check a certain file with for example query 'filename:/tmp/test/t1.txt', I get no results, because the slashes are converted to spaces when doing an exact match, or the query is split up into 'filename:tmp' , 'filename:test' and 'filename:t1.txt'. Which is _not_ what I want. 
> 
> What can I do to check for a complete file path?

Do not use the QueryParser.
You do not want an Analyzer, so just create a TermQuery directly.

-- 
   Roberto Ragusa    mail at robertoragusa.it

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