pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / facet / src / java / org / apache / lucene / facet / search / params / association / AssociationIntSumFacetRequest.java
1 package org.apache.lucene.facet.search.params.association;
2
3 import java.io.IOException;
4
5 import org.apache.lucene.index.IndexReader;
6
7 import org.apache.lucene.facet.search.FacetArrays;
8 import org.apache.lucene.facet.search.aggregator.Aggregator;
9 import org.apache.lucene.facet.search.aggregator.association.AssociationIntSumAggregator;
10 import org.apache.lucene.facet.search.params.FacetRequest;
11 import org.apache.lucene.facet.taxonomy.CategoryPath;
12 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
13
14 /**
15  * Licensed to the Apache Software Foundation (ASF) under one or more
16  * contributor license agreements.  See the NOTICE file distributed with
17  * this work for additional information regarding copyright ownership.
18  * The ASF licenses this file to You under the Apache License, Version 2.0
19  * (the "License"); you may not use this file except in compliance with
20  * the License.  You may obtain a copy of the License at
21  *
22  *     http://www.apache.org/licenses/LICENSE-2.0
23  *
24  * Unless required by applicable law or agreed to in writing, software
25  * distributed under the License is distributed on an "AS IS" BASIS,
26  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27  * See the License for the specific language governing permissions and
28  * limitations under the License.
29  */
30
31 /**
32  * Facet request for weighting facets according to their integer association by
33  * summing the association values.
34  * 
35  * @lucene.experimental
36  */
37 public class AssociationIntSumFacetRequest extends FacetRequest {
38
39   /**
40    * Create an integer association facet request for a given node in the
41    * taxonomy.
42    */
43   public AssociationIntSumFacetRequest(CategoryPath path, int num) {
44     super(path, num);
45   }
46
47   @Override
48   public Aggregator createAggregator(boolean useComplements,
49                                       FacetArrays arrays, IndexReader reader,
50                                       TaxonomyReader taxonomy) throws IOException {
51     assert !useComplements : "complements are not supported by this FacetRequest";
52     return new AssociationIntSumAggregator(reader, arrays.getIntArray());
53   }
54
55   @Override
56   public double getValueOf(FacetArrays arrays, int ordinal) {
57     return arrays.getIntArray()[ordinal];
58   }
59
60   @Override
61   public boolean supportsComplements() {
62     return false;
63   }
64   
65   @Override
66   public boolean requireDocumentScore() {
67     return false;
68   }
69   
70 }