Book Image

Lucene 4 Cookbook

By : Edwood Ng, Vineeth Mohan
Book Image

Lucene 4 Cookbook

By: Edwood Ng, Vineeth Mohan

Overview of this book

Table of Contents (16 chapters)
Lucene 4 Cookbook
About the Authors
About the Reviewers

Using Collectors

Collector is an advanced feature that deals with the low-level handling of search results data. The implementation of this class is necessary to produce usable search results. When we call the methods, we are actually already using Collector under the hood. So, what exactly is Collector? You can think of it as a refinery of search results after documents are matched. The matched documents are sent to Collector to score and sort. The default Collector we use in is called TopScoreDocCollector. It scores documents using a scorer and sorts results based on the scores.

Normally, you shouldn't have to mess with Collector. However, on a rare occasion when you need more control over how the matched documents are scored, sorted, or even filtered, Collector can be a good place to work on the customization. This is assuming that you have already exhausted the options of custom filter, similarity, and/or analyzer.

How to do it...

Let's take a look...