Chapter 3. Adding search to your application
This chapter covers
- Querying a Lucene index
- Using Lucene’s diverse built-in queries
- Working with search results
- Understanding Lucene scoring
- Parsing human-entered query expressions
The previous chapter showed you in great detail how to build a search index in preparation for searching. As fun as indexing is, it’s just a means to an end, a necessary evil, and its value only becomes clear once you enable searching on top of it. In this chapter, we’ll show you how to capitalize on all your indexing efforts. For example, consider this scenario:
Give me a list of all books published in the last 12 months on the subject of “Java” where “open source” or “Jakarta” is mentioned in the contents. Restrict the results to only books that are on special. Oh, and under the covers, also ensure that books mentioning “Apache” are picked up, because we explicitly specified “Jakarta.” And make it snappy, on the order of milliseconds for response time.