~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/contrib/facet/src/examples/org/apache/lucene/facet/example/adaptive/AdaptiveMain.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.lucene.facet.example.adaptive;
2
 
 
3
 
import java.util.List;
4
 
 
5
 
import org.apache.lucene.store.Directory;
6
 
import org.apache.lucene.store.RAMDirectory;
7
 
 
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;
14
 
 
15
 
/**
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
22
 
 *
23
 
 *     http://www.apache.org/licenses/LICENSE-2.0
24
 
 *
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.
30
 
 */
31
 
 
32
 
/**
33
 
 * Driver for the adaptive sample, using the {@link AdaptiveFacetsAccumulator}.
34
 
 * Indexing is the same as in {@link SimpleSearcher}
35
 
 * 
36
 
 * @lucene.experimental
37
 
 */
38
 
public class AdaptiveMain {
39
 
 
40
 
  /**
41
 
   * Driver for the adaptive sample.
42
 
   * @throws Exception on error (no detailed exception handling here for sample simplicity
43
 
   */
44
 
  public static void main(String[] args) throws Exception {
45
 
    new AdaptiveMain().runSample();
46
 
    ExampleUtils.log("DONE");
47
 
  }
48
 
 
49
 
  public ExampleResult runSample() throws Exception {
50
 
 
51
 
    // create Directories for the search index and for the taxonomy index
52
 
    Directory indexDir = new RAMDirectory();
53
 
    Directory taxoDir = new RAMDirectory();
54
 
 
55
 
    // index the sample documents
56
 
    ExampleUtils.log("index the adaptive sample documents...");
57
 
    SimpleIndexer.index(indexDir, taxoDir);
58
 
 
59
 
    ExampleUtils.log("search the adaptive sample documents...");
60
 
    List<FacetResult> facetRes = AdaptiveSearcher.searchWithFacets(indexDir, taxoDir);
61
 
 
62
 
    ExampleResult res = new ExampleResult();
63
 
    res.setFacetResults(facetRes);
64
 
    return res;
65
 
  }
66
 
 
67
 
}