-
Notifications
You must be signed in to change notification settings - Fork 242
/
LuceneGeoPointFieldAggregationBuilderFactory.java
58 lines (49 loc) · 2.45 KB
/
LuceneGeoPointFieldAggregationBuilderFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.search.backend.lucene.types.aggregation.impl;
import java.lang.invoke.MethodHandles;
import org.hibernate.search.backend.lucene.logging.impl.Log;
import org.hibernate.search.backend.lucene.search.impl.LuceneSearchContext;
import org.hibernate.search.backend.lucene.types.codec.impl.LuceneFieldCodec;
import org.hibernate.search.engine.backend.types.converter.spi.ProjectionConverter;
import org.hibernate.search.engine.backend.types.converter.spi.DslConverter;
import org.hibernate.search.engine.reporting.spi.EventContexts;
import org.hibernate.search.engine.search.aggregation.spi.RangeAggregationBuilder;
import org.hibernate.search.engine.search.aggregation.spi.TermsAggregationBuilder;
import org.hibernate.search.engine.search.common.ValueConvert;
import org.hibernate.search.engine.spatial.GeoPoint;
import org.hibernate.search.util.common.logging.impl.LoggerFactory;
public class LuceneGeoPointFieldAggregationBuilderFactory
extends AbstractLuceneFieldAggregationBuilderFactory<GeoPoint> {
private static final Log log = LoggerFactory.make( Log.class, MethodHandles.lookup() );
private final LuceneFieldCodec<GeoPoint> codec;
public LuceneGeoPointFieldAggregationBuilderFactory(boolean aggregable,
DslConverter<?, ? extends GeoPoint> toFieldValueConverter,
ProjectionConverter<? super GeoPoint, ?> fromFieldValueConverter,
LuceneFieldCodec<GeoPoint> codec) {
super( aggregable, toFieldValueConverter, fromFieldValueConverter );
this.codec = codec;
}
@Override
public <K> TermsAggregationBuilder<K> createTermsAggregationBuilder(LuceneSearchContext searchContext,
String nestedDocumentPath, String absoluteFieldPath, Class<K> expectedType, ValueConvert convert) {
throw log.directValueLookupNotSupportedByGeoPoint(
EventContexts.fromIndexFieldAbsolutePath( absoluteFieldPath )
);
}
@Override
public <K> RangeAggregationBuilder<K> createRangeAggregationBuilder(LuceneSearchContext searchContext,
String nestedDocumentPath, String absoluteFieldPath, Class<K> expectedType, ValueConvert convert) {
throw log.rangesNotSupportedByGeoPoint(
EventContexts.fromIndexFieldAbsolutePath( absoluteFieldPath )
);
}
@Override
protected LuceneFieldCodec<GeoPoint> getCodec() {
return codec;
}
}