// Path: lucene/src/main/java/de/fhopf/lucenesolrtalk/Result.java
// public class Result {
// 
//     private final String title;
//     private final String excerpt;
//     private final List<String> categories;
//     private final List<String> speakers;
//     private final Date date;
// 
//     public Result(String title, String excerpt, List<String> categories, List<String> speakers, Date date) {
//         this.title = title;
//         this.excerpt = excerpt;
//         this.categories = categories;
//         this.speakers = speakers;
//         this.date = date;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public String getExcerpt() {
//         return excerpt;
//     }
// 
//     public List<String> getCategories() {
//         return categories;
//     }
// 
//     public List<String> getSpeakers() {
//         return speakers;
//     }
// 
//     public Date getDate() {
//         return date;
//     }
// }


import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import de.fhopf.lucenesolrtalk.Result;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.de.GermanAnalyzer;
import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.*;
import org.apache.lucene.search.highlight.*;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package de.fhopf.lucenesolrtalk.lucene;


/**
 * Searches on an index.
 *
 * Note: When used from a webapp this implementation is not as efficient as it should be. On each request it opens
 * a new IndexReader which can be quite costly. If you are interested in how to implement a SearchManager that takes
 * care of opening and updating IndexReaders have a look at Chapter 11 of Lucene in Action.
 */
public class Searcher {

    private Logger logger = LoggerFactory.getLogger(Searcher.class);

    private final Directory directory;

    public Searcher(Directory directory) {
        this.directory = directory;
    }

// Path: lucene/src/main/java/de/fhopf/lucenesolrtalk/Result.java
// public class Result {
// 
//     private final String title;
//     private final String excerpt;
//     private final List<String> categories;
//     private final List<String> speakers;
//     private final Date date;
// 
//     public Result(String title, String excerpt, List<String> categories, List<String> speakers, Date date) {
//         this.title = title;
//         this.excerpt = excerpt;
//         this.categories = categories;
//         this.speakers = speakers;
//         this.date = date;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public String getExcerpt() {
//         return excerpt;
//     }
// 
//     public List<String> getCategories() {
//         return categories;
//     }
// 
//     public List<String> getSpeakers() {
//         return speakers;
//     }
// 
//     public Date getDate() {
//         return date;
//     }
// }


// Path: lucene/src/main/java/de/fhopf/lucenesolrtalk/lucene/Searcher.java
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import de.fhopf.lucenesolrtalk.Result;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.de.GermanAnalyzer;
import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.*;
import org.apache.lucene.search.highlight.*;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

package de.fhopf.lucenesolrtalk.lucene;


/**
 * Searches on an index.
 *
 * Note: When used from a webapp this implementation is not as efficient as it should be. On each request it opens
 * a new IndexReader which can be quite costly. If you are interested in how to implement a SearchManager that takes
 * care of opening and updating IndexReaders have a look at Chapter 11 of Lucene in Action.
 */
public class Searcher {

    private Logger logger = LoggerFactory.getLogger(Searcher.class);

    private final Directory directory;

    public Searcher(Directory directory) {
        this.directory = directory;
    }

    private List<Result> search(Query query, Optional<Sort> sort) {