A Beginner's Guide to Searching With Lucene
@@ -27,7 +53,7 @@The Use Case
+The Use Case
Before we dive into the code, it's important to make sure that you actually need an indexing and searching tool that goes beyond simple SQL queries.
@@ -42,7 +68,7 @@Indexing and Searching Basics
+Indexing and Searching Basics
No matter what searching solution you end up choosing, they all generally follow the same approach:
@@ -64,7 +90,7 @@Setting Up a New Project
+Setting Up a New Project
In this guide, I'll be creating a small Java program for searching over a huge set of airports which is available for free here: https://ourairports.com/data/. The full source code for this project is available on GitHub, if you'd like to take a look.
@@ -94,7 +120,7 @@Parsing the Data
+Parsing the Data
First of all, we need to parse the CSV data into a programming construct that we can use elsewhere in our code. In this case, I've defined the Airport
record like so:
Indexing
+Indexing
In order to efficiently search over a massive set of data, we need to prepare a special set of index files that Lucene can read during searches. To do that, we need to create a new directory for the index to live in, construct a new IndexWriter, and create a Document for each airport we're indexing.
@@ -187,7 +213,7 @@Searching
+Searching
Now that we've built an index from our dataset, we can search over it to find the most relevant results for a user's query.
@@ -260,12 +286,9 @@Once again, my sample code is available on GitHub here.
-