Skip to content

An example of how to use Apache Lucene for indexing and searching files...

Notifications You must be signed in to change notification settings

jpaulynice/lucene-index-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lucene-Index-Search-Example

This is a simple example of how to use apache lucene to index and search a directory.

Currently, the application is set to index files ending in java which can be changed in the main method of Indexer.java

package com.search.demo;

import com.search.FileIndexer;
import com.search.impl.FileIndexerImpl;

public class Indexer {
    /**
     * Main method to index directory
     *
     * @param args
     */
    public static void main(final String[] args){
        final String dirToIndex = "/Users/julespaulynice/Documents/workspace";
        final String suffix = "java";

        final FileIndexer indexer = new FileIndexerImpl();
        indexer.index(dirToIndex, suffix);
    }
}

Then search for "lucene" and list the file paths that match our query.

package com.search.demo;

import com.search.FileSearcher;
import com.search.impl.FileSearcherImpl;

public class Searcher {
    /**
     * Main method to search directory
     *
     * @param args
     */
    public static void main(final String[] args) {
        final String query = "lucene";
        final int hits = 100;

        final FileSearcher searcher = new FileSearcherImpl();
        searcher.search(query, hits);
    }
}

About

An example of how to use Apache Lucene for indexing and searching files...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages