Indexing a dir recursively and ignoring files

  • Issahar (Jus) Weiss

    I am trying to use LIUS.
    I want to index a directory with its sub-directories, but I want it to ignore certain files, like JPG, SWF and others.
    How do I do it?
    My code is this:
        String loggerProp = "D:\\Lius-1.0\\Config\\log4j\\";
        String liusCfg = "D:\\Lius-1.0\\Config\\liusConfig.xml";
        String LIUS_IDX = "d:\\liusIdx";
        String toIndex = "d:\\liusDirectory";


        LiusConfig lc = LiusConfigBuilder.getSingletonInstance().getLiusConfig(liusCfg);

        LuceneActions.getSingletonInstance().indexSubDirectories(new File(toIndex), LIUS_IDX, lc);

    As I understand it, in LuceneActions.fileDirectoryProcessing :
            indexer = IndexerFactory.getIndexer(f, lc);
            if (indexer != null) {
                Document doc = LuceneActions.getSingletonInstance()
                doc.add(new Field("filePath", f.getAbsolutePath(),
                        Field.Store.YES, Field.Index.UN_TOKENIZED));
    if you want to ignore a file, it means that the IndexerFactory.getIndexer(f, lc) should return null for that file.
    but if you look into that method:
            try {
                indexer = getIndexer(new FileInputStream(file),MimeTypeUtils.getMimeType(file) , lc);
            } catch (FileNotFoundException e) {
            return indexer;
    if the call for getIndexer will return null, we'll get NullPointerException, which I indeed get.

    So, is it a bug, or I just don't know how to ignore files?
    thanx very much,

  • Jaya Bansal

    Jaya Bansal - 2010-05-03

    I am searching for the same - How can I exclude some files and folders from searching? Can anybody help?


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks