Indexing a dir recursively and ignoring files

Help
2007-04-30
2013-04-17
  • Hi.
    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\\log4j.properties";
        String liusCfg = "D:\\Lius-1.0\\Config\\liusConfig.xml";
        String LIUS_IDX = "d:\\liusIdx";
        String toIndex = "d:\\liusDirectory";

        LiusLogger.setLoggerConfigFile(loggerProp);

        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()
                        .populateLuceneDoc(indexer.getPopulatedLiusFields());
                doc.add(new Field("filePath", f.getAbsolutePath(),
                        Field.Store.YES, Field.Index.UN_TOKENIZED));
                iw.addDocument(doc);
            }
    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:
    IndexerFactory.getIndexer:
            try {
                indexer = getIndexer(new FileInputStream(file),MimeTypeUtils.getMimeType(file) , lc);
                indexer.setDocToIndexPath(file.getAbsolutePath());
               
            } catch (FileNotFoundException e) {
                logger.error(e.getMessage());
            }
            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,
    Issahar.

     
  • 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?