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