add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / facet / src / examples / org / apache / lucene / facet / example / association / AssociationMain.java
1 package org.apache.lucene.facet.example.association;
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.search.results.FacetResult;
11
12 /**
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
19  *
20  *     http://www.apache.org/licenses/LICENSE-2.0
21  *
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.
27  */
28
29 /**
30  * Driver for the simple sample.
31  * 
32  * @lucene.experimental
33  */
34 public class AssociationMain {
35
36   /**
37    * Driver for the simple sample.
38    * @throws Exception on error (no detailed exception handling here for sample simplicity
39    */
40   public static void main(String[] args) throws Exception {
41     new AssociationMain().runSumIntAssociationSample();
42     new AssociationMain().runSumFloatAssociationSample();
43     ExampleUtils.log("DONE");
44   }
45
46   public ExampleResult runSumIntAssociationSample() throws Exception {
47
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();
51
52     // index the sample documents
53     ExampleUtils.log("index the sample documents...");
54     AssociationIndexer.index(indexDir, taxoDir);
55
56     ExampleUtils.log("search the sample documents...");
57     List<FacetResult> facetRes = AssociationSearcher.searchSumIntAssociation(indexDir, taxoDir);
58
59     ExampleResult res = new ExampleResult();
60     res.setFacetResults(facetRes);
61     return res;
62   }
63   
64   public ExampleResult runSumFloatAssociationSample() throws Exception {
65     
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();
69     
70     // index the sample documents
71     ExampleUtils.log("index the sample documents...");
72     AssociationIndexer.index(indexDir, taxoDir);
73     
74     ExampleUtils.log("search the sample documents...");
75     List<FacetResult> facetRes = AssociationSearcher.searchSumFloatAssociation(indexDir, taxoDir);
76     
77     ExampleResult res = new ExampleResult();
78     res.setFacetResults(facetRes);
79     return res;
80   }
81
82 }