1 package org.apache.lucene.facet.example.adaptive;
5 import org.apache.lucene.store.Directory;
6 import org.apache.lucene.store.RAMDirectory;
8 import org.apache.lucene.facet.example.ExampleResult;
9 import org.apache.lucene.facet.example.ExampleUtils;
10 import org.apache.lucene.facet.example.simple.SimpleIndexer;
11 import org.apache.lucene.facet.example.simple.SimpleSearcher;
12 import org.apache.lucene.facet.search.AdaptiveFacetsAccumulator;
13 import org.apache.lucene.facet.search.results.FacetResult;
16 * Licensed to the Apache Software Foundation (ASF) under one or more
17 * contributor license agreements. See the NOTICE file distributed with
18 * this work for additional information regarding copyright ownership.
19 * The ASF licenses this file to You under the Apache License, Version 2.0
20 * (the "License"); you may not use this file except in compliance with
21 * the License. You may obtain a copy of the License at
23 * http://www.apache.org/licenses/LICENSE-2.0
25 * Unless required by applicable law or agreed to in writing, software
26 * distributed under the License is distributed on an "AS IS" BASIS,
27 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28 * See the License for the specific language governing permissions and
29 * limitations under the License.
33 * Driver for the adaptive sample, using the {@link AdaptiveFacetsAccumulator}.
34 * Indexing is the same as in {@link SimpleSearcher}
36 * @lucene.experimental
38 public class AdaptiveMain {
41 * Driver for the adaptive sample.
42 * @throws Exception on error (no detailed exception handling here for sample simplicity
44 public static void main(String[] args) throws Exception {
45 new AdaptiveMain().runSample();
46 ExampleUtils.log("DONE");
49 public ExampleResult runSample() throws Exception {
51 // create Directories for the search index and for the taxonomy index
52 Directory indexDir = new RAMDirectory();
53 Directory taxoDir = new RAMDirectory();
55 // index the sample documents
56 ExampleUtils.log("index the adaptive sample documents...");
57 SimpleIndexer.index(indexDir, taxoDir);
59 ExampleUtils.log("search the adaptive sample documents...");
60 List<FacetResult> facetRes = AdaptiveSearcher.searchWithFacets(indexDir, taxoDir);
62 ExampleResult res = new ExampleResult();
63 res.setFacetResults(facetRes);