1 package org.apache.lucene.facet.example.association;
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.search.results.FacetResult;
13 * Licensed to the Apache Software Foundation (ASF) under one or more
14 * contributor license agreements. See the NOTICE file distributed with
15 * this work for additional information regarding copyright ownership.
16 * The ASF licenses this file to You under the Apache License, Version 2.0
17 * (the "License"); you may not use this file except in compliance with
18 * the License. You may obtain a copy of the License at
20 * http://www.apache.org/licenses/LICENSE-2.0
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an "AS IS" BASIS,
24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
30 * Driver for the simple sample.
32 * @lucene.experimental
34 public class AssociationMain {
37 * Driver for the simple sample.
38 * @throws Exception on error (no detailed exception handling here for sample simplicity
40 public static void main(String[] args) throws Exception {
41 new AssociationMain().runSumIntAssociationSample();
42 new AssociationMain().runSumFloatAssociationSample();
43 ExampleUtils.log("DONE");
46 public ExampleResult runSumIntAssociationSample() throws Exception {
48 // create Directories for the search index and for the taxonomy index
49 Directory indexDir = new RAMDirectory();//FSDirectory.open(new File("/tmp/111"));
50 Directory taxoDir = new RAMDirectory();
52 // index the sample documents
53 ExampleUtils.log("index the sample documents...");
54 AssociationIndexer.index(indexDir, taxoDir);
56 ExampleUtils.log("search the sample documents...");
57 List<FacetResult> facetRes = AssociationSearcher.searchSumIntAssociation(indexDir, taxoDir);
59 ExampleResult res = new ExampleResult();
60 res.setFacetResults(facetRes);
64 public ExampleResult runSumFloatAssociationSample() throws Exception {
66 // create Directories for the search index and for the taxonomy index
67 Directory indexDir = new RAMDirectory();//FSDirectory.open(new File("/tmp/111"));
68 Directory taxoDir = new RAMDirectory();
70 // index the sample documents
71 ExampleUtils.log("index the sample documents...");
72 AssociationIndexer.index(indexDir, taxoDir);
74 ExampleUtils.log("search the sample documents...");
75 List<FacetResult> facetRes = AssociationSearcher.searchSumFloatAssociation(indexDir, taxoDir);
77 ExampleResult res = new ExampleResult();
78 res.setFacetResults(facetRes);