LucenePlugin
Written by: Matthieu Casanova, Shlomy Reinstein.
Creating an index
Searching an index
Deleting an index
Support
LucenePlugin allows you to perform quick and complex text searches using the
Lucene search engine. It can save you a lot of time when searching across
projects, directory trees or large files. It builds up an index for the text
in the files, and enables you to search this index efficiently.
Information about Lucene is available on the
Lucene website.
The plugin allows you to create a Lucene index, using one of the built-in
analyzers, and then search the index. Once created, the index remains updated
when the files in it are changed inside jEdit (i.e. when their buffers are
saved). If the files in the index are changed externally (e.g. by updating them
from a version control system), you can ask the plugin to update the index.
Creating an index:
-
Select the files to index.
-
To create an index for a project, right-click the project in the ProjectViewer
dockable window, and select "Index in Lucene".
-
To create an index for a directory tree, right-click the root of the directory
tree in the File System Browser dockable window, and select Plugins ->
LucenePlugin -> Add selected file(s) to a new index.
You can later add more files / directories to an existing index by selecting
"Add selected file(s) to an existing index".
-
The "New Lucene Index" dialog will show up. Fill-in the details.
-
If this is not a project index, specify the index name.
-
Select the type of index: Line-based or file-based. A file-based index creates
a Lucene document for each file, whereas a line-based index creates a Lucene
document for each line in each file. A line-based index is a lot larger than
a file-based index; its only advantage is that there is no need to scan the file
again later to find which lines contain the words you search for. Both types of
index can produce the line numbers where the words occur, but the file-based
index will require an additional scan of the files containing the words in order
to produce the line numbers. A line-based index may be appropriate if you're
indexing network files with very slow access.
-
Select the analyzer to use for indexing. If you are not familiar with analyzers,
use "Java identifier" for source code, which allows you to look for precise
identifier occurrences, and "Standard" for text, or check the Lucene website for
information about the other analyzers. A brief description of the analyzers:
- Standard: Most suitable for free text - uses a sophisticated grammar
to extract words, removes stop words and lowercases.
- Keyword: Treats entire text as a single token.
- Simple: Divides text at nonletter characters and lowercases.
- Java identifier: Suitable for source code - extracts identifier
names from the text and stores them without change.
- Whitespace: Splits tokens at whitespace.
- Stop: Divides text at nonletter characters, lowercases, and removes
stop words ("a", "an", "are" ...).
For more information, check the
Analyzer documentation
, or more briefly
Using the Built-in Analyzers in Lucene
.
-
Click Ok to start creating the index.
Searching an index:
-
Open the "Search with Lucene" dockable window using Plugins -> LucenePlugin ->
Lucene Search .
-
Select the index to search in the combo-box on the right of the dockable.
-
Specify the maximal number of results that you want to get for your search in
the "Max results:" box.
-
If you'd like to see the line numbers where the search matches, select the
'Line-based results' check-box. If the index is file-based, the files that
match will be re-scanned to find the line numbers.
-
If you'd like to constrain the search to a specific file extension, enter the
extension in the 'file type:' box.
-
Finally, enter the words to search for in the "Search for:" box. For those
familiar with Lucene, this can be any Lucene query, not just words.
Click [Enter] to perform the search.
The rightmost button in the dockable toggles between multiple results and a
single-result, much like the "Hypersearch Results" dockable of jEdit. The
button to its left clears all previous results that are currently shown.
While an index is being created or updated, the word "Indexing" will show on
the right of the dockable when that index is selected for searching, so you
know that the index is not yet complete.
Deleting an index:
Select Plugins -> Lucene -> Delete an index, then select the index you'd like to
delete.
Support