Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Lucene 4 Cookbook
  • Toc
  • feedback
Lucene 4 Cookbook

Lucene 4 Cookbook

By : Edwood Ng, Vineeth Mohan
3.2 (5)
close
Lucene 4 Cookbook

Lucene 4 Cookbook

3.2 (5)
By: Edwood Ng, Vineeth Mohan

Overview of this book

This book is for software developers who are new to Lucene and who want to explore the more advanced topics to build a search engine. Knowledge of Java is necessary to follow the code samples. You will learn core concepts, best practices, and also advanced features, in order to build an effective search application.
Table of Contents (11 chapters)
close
10
Index

Constructing queries


Now that we have an IndexSearcher, we are ready to proceed to querying. To begin, we will need to construct a Query object to pass into IndexSearch's search method. There are a couple ways to construct a Query. Using a QueryParser class or constructing a Query programmatically, QueryParser provides the utility to interpret text and convert it into a Query. If you need to use search modifiers (for example, term must exist), there is a certain syntax to follow in order to form a query string. By default, a search phrase will return any documents that have matches on any of the query terms. We will demonstrate both QueryParser and constructing your own Query in this section.

Note

Note that if you use QueryParser, you must also use an analyzer to analyze the query text.

How to do it...

Let's take a look at the following code snippets:

Code snippet 1:

Directory directory = 
    FSDirectory.open(new File("/data/index"));
IndexReader indexReader = DirectoryReader.open(directory...
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete