mirror of https://github.com/apache/lucene.git
LUCENE-5339: organize packages
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5339@1554379 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d2c4dfca04
commit
cfe57ec320
|
@ -23,17 +23,15 @@ import java.util.List;
|
|||
|
||||
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.FloatAssociationFacetField;
|
||||
import org.apache.lucene.facet.IntAssociationFacetField;
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.TaxonomyFacetSumFloatAssociations;
|
||||
import org.apache.lucene.facet.TaxonomyFacetSumIntAssociations;
|
||||
import org.apache.lucene.facet.taxonomy.FacetLabel;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.taxonomy.FloatAssociationFacetField;
|
||||
import org.apache.lucene.facet.taxonomy.IntAssociationFacetField;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyFacetSumFloatAssociations;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyFacetSumIntAssociations;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
|
|
|
@ -28,12 +28,12 @@ import org.apache.lucene.document.Field;
|
|||
import org.apache.lucene.expressions.Expression;
|
||||
import org.apache.lucene.expressions.SimpleBindings;
|
||||
import org.apache.lucene.expressions.js.JavascriptCompiler;
|
||||
import org.apache.lucene.facet.DoubleRange;
|
||||
import org.apache.lucene.facet.DoubleRangeFacetCounts;
|
||||
import org.apache.lucene.facet.DrillDownQuery;
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.range.DoubleRange;
|
||||
import org.apache.lucene.facet.range.DoubleRangeFacetCounts;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
|
|
|
@ -2,8 +2,6 @@ package org.apache.lucene.demo.facet;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
|
@ -14,12 +12,11 @@ import org.apache.lucene.expressions.Expression;
|
|||
import org.apache.lucene.expressions.SimpleBindings;
|
||||
import org.apache.lucene.expressions.js.JavascriptCompiler;
|
||||
import org.apache.lucene.facet.FacetField;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.TaxonomyFacetSumValueSource;
|
||||
import org.apache.lucene.facet.taxonomy.FacetLabel;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyFacetSumValueSource;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
|
|
@ -19,21 +19,17 @@ package org.apache.lucene.demo.facet;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.facet.FacetField;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.FastTaxonomyFacetCounts;
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.taxonomy.FacetLabel;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
|
|
|
@ -30,8 +30,8 @@ import org.apache.lucene.facet.FacetResult;
|
|||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.LongRange;
|
||||
import org.apache.lucene.facet.LongRangeFacetCounts;
|
||||
import org.apache.lucene.facet.range.LongRange;
|
||||
import org.apache.lucene.facet.range.LongRangeFacetCounts;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
|
|
|
@ -23,16 +23,14 @@ import java.util.List;
|
|||
|
||||
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.facet.FacetField;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.FastTaxonomyFacetCounts;
|
||||
import org.apache.lucene.facet.DrillDownQuery;
|
||||
import org.apache.lucene.facet.FacetField;
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.taxonomy.FacetLabel;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
|
|
|
@ -28,9 +28,9 @@ import org.apache.lucene.facet.FacetResult;
|
|||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.SortedSetDocValuesFacetCounts;
|
||||
import org.apache.lucene.facet.SortedSetDocValuesFacetField;
|
||||
import org.apache.lucene.facet.SortedSetDocValuesReaderState;
|
||||
import org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetCounts;
|
||||
import org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetField;
|
||||
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
|
|
|
@ -22,6 +22,8 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.facet.range.DoubleRangeFacetCounts;
|
||||
import org.apache.lucene.facet.range.LongRangeFacetCounts;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
|
|
|
@ -21,6 +21,10 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetCounts;
|
||||
import org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetField;
|
||||
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState;
|
||||
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.Term;
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package org.apache.lucene.facet;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** Required for javadocs generation. */
|
||||
public final class FacetPackage {
|
||||
|
||||
private FacetPackage() {}
|
||||
|
||||
}
|
|
@ -31,7 +31,11 @@ import org.apache.lucene.document.BinaryDocValuesField;
|
|||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.SortedSetDocValuesField;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetField;
|
||||
import org.apache.lucene.facet.taxonomy.AssociationFacetField;
|
||||
import org.apache.lucene.facet.taxonomy.FacetLabel;
|
||||
import org.apache.lucene.facet.taxonomy.FloatAssociationFacetField;
|
||||
import org.apache.lucene.facet.taxonomy.IntAssociationFacetField;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.index.IndexDocument;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
|
|
|
@ -21,11 +21,11 @@ import org.apache.lucene.util.PriorityQueue;
|
|||
|
||||
/** Keeps highest results, first by largest float value,
|
||||
* then tie break by smallest ord. */
|
||||
class TopOrdAndFloatQueue extends PriorityQueue<TopOrdAndFloatQueue.OrdAndValue> {
|
||||
public class TopOrdAndFloatQueue extends PriorityQueue<TopOrdAndFloatQueue.OrdAndValue> {
|
||||
|
||||
public static final class OrdAndValue {
|
||||
int ord;
|
||||
float value;
|
||||
public int ord;
|
||||
public float value;
|
||||
}
|
||||
|
||||
public TopOrdAndFloatQueue(int topN) {
|
||||
|
|
|
@ -21,11 +21,11 @@ import org.apache.lucene.util.PriorityQueue;
|
|||
|
||||
/** Keeps highest results, first by largest int value,
|
||||
* then tie break by smallest ord. */
|
||||
class TopOrdAndIntQueue extends PriorityQueue<TopOrdAndIntQueue.OrdAndValue> {
|
||||
public class TopOrdAndIntQueue extends PriorityQueue<TopOrdAndIntQueue.OrdAndValue> {
|
||||
|
||||
public static final class OrdAndValue {
|
||||
int ord;
|
||||
int value;
|
||||
public int ord;
|
||||
public int value;
|
||||
}
|
||||
|
||||
public TopOrdAndIntQueue(int topN) {
|
||||
|
|
|
@ -27,23 +27,23 @@
|
|||
<li> Taxonomy-based methods rely on a separate taxonomy index to
|
||||
map hierarchical facet paths to global int ordinals for fast
|
||||
counting at search time; these methods can compute counts
|
||||
(({@link org.apache.lucene.facet.FastTaxonomyFacetCounts}, {@link
|
||||
org.apache.lucene.facet.TaxonomyFacetCounts}) aggregate long or double values {@link
|
||||
org.apache.lucene.facet.TaxonomyFacetSumIntAssociations}, {@link
|
||||
org.apache.lucene.facet.TaxonomyFacetSumFloatAssociations}, {@link
|
||||
org.apache.lucene.facet.TaxonomyFacetSumValueSource}. Add {@link org.apache.lucene.facet.FacetField} or
|
||||
{@link org.apache.lucene.facet.AssociationFacetField} to your documents at index time
|
||||
(({@link org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts}, {@link
|
||||
org.apache.lucene.facet.taxonomy.TaxonomyFacetCounts}) aggregate long or double values {@link
|
||||
org.apache.lucene.facet.taxonomy.TaxonomyFacetSumIntAssociations}, {@link
|
||||
org.apache.lucene.facet.taxonomy.TaxonomyFacetSumFloatAssociations}, {@link
|
||||
org.apache.lucene.facet.taxonomy.TaxonomyFacetSumValueSource}. Add {@link org.apache.lucene.facet.FacetField} or
|
||||
{@link org.apache.lucene.facet.taxonomy.AssociationFacetField} to your documents at index time
|
||||
to use taxonomy-based methods.
|
||||
|
||||
<li> Sorted-set doc values method does not require a separate
|
||||
taxonomy index, and computes counts based on sorted set doc
|
||||
values fields ({@link org.apache.lucene.facet.SortedSetDocValuesFacetCounts}). Add
|
||||
{@link org.apache.lucene.facet.SortedSetDocValuesFacetField} to your documents at
|
||||
values fields ({@link org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetCounts}). Add
|
||||
{@link org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetField} to your documents at
|
||||
index time to use sorted set facet counts.
|
||||
|
||||
<li> Range faceting {@link org.apache.lucene.facet.LongRangeFacetCounts}, {@link
|
||||
org.apache.lucene.facet.DoubleRangeFacetCounts} compute counts for a dynamic numeric
|
||||
range from a provided {@link org.apache.lucene.facet.ValueSource} (previously indexed
|
||||
<li> Range faceting {@link org.apache.lucene.facet.range.LongRangeFacetCounts}, {@link
|
||||
org.apache.lucene.facet.range.DoubleRangeFacetCounts} compute counts for a dynamic numeric
|
||||
range from a provided {@link org.apache.lucene.queries.function.ValueSource} (previously indexed
|
||||
numeric field, or a dynamic expression such as distance).
|
||||
</ul>
|
||||
</p>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.range;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.range;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -23,6 +23,8 @@ import java.util.List;
|
|||
|
||||
import org.apache.lucene.document.DoubleDocValuesField; // javadocs
|
||||
import org.apache.lucene.document.FloatDocValuesField; // javadocs
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsCollector.MatchingDocs;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.range;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.range;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.range;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -21,6 +21,8 @@ import java.io.IOException;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsCollector.MatchingDocs;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.range;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.range;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -21,9 +21,11 @@ import java.io.IOException;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.LabelAndValue;
|
||||
import org.apache.lucene.queries.function.valuesource.LongFieldSource;
|
||||
|
||||
|
||||
/** Base class for range faceting.
|
||||
*
|
||||
* @lucene.experimental */
|
|
@ -0,0 +1,24 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Range Facets</title>
|
||||
</head>
|
||||
<body>
|
||||
Provides range faceting capabilities.
|
||||
</body>
|
||||
</html>
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.sortedset;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -24,12 +24,18 @@ import java.util.Comparator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsCollector.MatchingDocs;
|
||||
import org.apache.lucene.facet.SortedSetDocValuesReaderState.OrdRange;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.LabelAndValue;
|
||||
import org.apache.lucene.facet.TopOrdAndIntQueue;
|
||||
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState.OrdRange;
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.MultiDocValues.MultiSortedSetDocValues;
|
||||
import org.apache.lucene.index.MultiDocValues;
|
||||
import org.apache.lucene.index.MultiDocValues.MultiSortedSetDocValues;
|
||||
import org.apache.lucene.index.ReaderUtil;
|
||||
import org.apache.lucene.index.SortedSetDocValues;
|
||||
import org.apache.lucene.util.BytesRef;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.sortedset;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -23,13 +23,16 @@ import org.apache.lucene.document.FieldType;
|
|||
/** Add an instance of this to your Document for every facet
|
||||
* label to be indexed via SortedSetDocValues. */
|
||||
public class SortedSetDocValuesFacetField extends Field {
|
||||
static final FieldType TYPE = new FieldType();
|
||||
|
||||
/** Indexed {@link FieldType}. */
|
||||
public static final FieldType TYPE = new FieldType();
|
||||
static {
|
||||
TYPE.setIndexed(true);
|
||||
TYPE.freeze();
|
||||
}
|
||||
final String dim;
|
||||
final String label;
|
||||
|
||||
public final String dim;
|
||||
public final String label;
|
||||
|
||||
public SortedSetDocValuesFacetField(String dim, String label) {
|
||||
super("dummy", TYPE);
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.sortedset;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -22,6 +22,7 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.SlowCompositeReaderWrapper;
|
|
@ -0,0 +1,25 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>SortedSet Facets</title>
|
||||
</head>
|
||||
<body>
|
||||
Provides faceting capabilities over facets that were indexed with {@link org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetField}.
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -22,6 +22,7 @@ import java.util.Arrays;
|
|||
import org.apache.lucene.document.Document; // javadocs
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
/** Add an instance of this to your {@link Document} to add
|
||||
|
@ -35,14 +36,16 @@ import org.apache.lucene.util.BytesRef;
|
|||
* @lucene.experimental */
|
||||
public class AssociationFacetField extends Field {
|
||||
|
||||
static final FieldType TYPE = new FieldType();
|
||||
/** Indexed {@link FieldType}. */
|
||||
public static final FieldType TYPE = new FieldType();
|
||||
static {
|
||||
TYPE.setIndexed(true);
|
||||
TYPE.freeze();
|
||||
}
|
||||
protected final String dim;
|
||||
protected final String[] path;
|
||||
protected final BytesRef assoc;
|
||||
|
||||
public final String dim;
|
||||
public final String[] path;
|
||||
public final BytesRef assoc;
|
||||
|
||||
/** Creates this from {@code dim} and {@code path} and an
|
||||
* association */
|
||||
|
@ -56,16 +59,6 @@ public class AssociationFacetField extends Field {
|
|||
this.path = path;
|
||||
}
|
||||
|
||||
// private static BytesRef intToBytesRef(int v) {
|
||||
// byte[] bytes = new byte[4];
|
||||
// // big-endian:
|
||||
// bytes[0] = (byte) (v >> 24);
|
||||
// bytes[1] = (byte) (v >> 16);
|
||||
// bytes[2] = (byte) (v >> 8);
|
||||
// bytes[3] = (byte) v;
|
||||
// return new BytesRef(bytes);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AssociationFacetField(dim=" + dim + " path=" + Arrays.toString(path) + " bytes=" + assoc + ")";
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -20,8 +20,9 @@ package org.apache.lucene.facet;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.FacetsCollector.MatchingDocs;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.index.BinaryDocValues;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.FixedBitSet;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -20,13 +20,14 @@ package org.apache.lucene.facet;
|
|||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.FacetsConfig.DimConfig;
|
||||
import org.apache.lucene.facet.taxonomy.FacetLabel;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.LabelAndValue;
|
||||
import org.apache.lucene.facet.TopOrdAndFloatQueue;
|
||||
|
||||
/** Base class for all taxonomy-based facets that aggregate
|
||||
* to a per-ords float[]. */
|
||||
|
||||
public abstract class FloatTaxonomyFacets extends TaxonomyFacets {
|
||||
|
||||
protected final float[] values;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -20,9 +20,11 @@ package org.apache.lucene.facet;
|
|||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.FacetsConfig.DimConfig;
|
||||
import org.apache.lucene.facet.taxonomy.FacetLabel;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.LabelAndValue;
|
||||
import org.apache.lucene.facet.TopOrdAndIntQueue;
|
||||
|
||||
/** Base class for all taxonomy-based facets that aggregate
|
||||
* to a per-ords int[]. */
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -19,7 +19,6 @@ package org.apache.lucene.facet;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -20,8 +20,10 @@ package org.apache.lucene.facet;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsCollector.MatchingDocs;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.OrdinalsReader;
|
||||
import org.apache.lucene.index.BinaryDocValues;
|
||||
import org.apache.lucene.util.FixedBitSet;
|
||||
import org.apache.lucene.util.IntsRef;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -20,8 +20,9 @@ package org.apache.lucene.facet;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.FacetsCollector.MatchingDocs;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.index.BinaryDocValues;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.FixedBitSet;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -20,8 +20,9 @@ package org.apache.lucene.facet;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.FacetsCollector.MatchingDocs;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.index.BinaryDocValues;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.FixedBitSet;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -22,8 +22,11 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.facet.DocValuesOrdinalsReader;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsCollector.MatchingDocs;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.OrdinalsReader;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
|
@ -126,9 +129,10 @@ public class TaxonomyFacetSumValueSource extends FloatTaxonomyFacets {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Override public boolean equals(Object o) { return o == this; }
|
||||
@Override public int hashCode() { return System.identityHashCode(this); }
|
||||
@Override public String description() { return "score()"; }
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -23,11 +23,26 @@ import java.util.Collections;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.facet.taxonomy.ParallelTaxonomyArrays;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
|
||||
/** Base class for all taxonomy-based facets impls. */
|
||||
public abstract class TaxonomyFacets extends Facets {
|
||||
|
||||
private static final Comparator<FacetResult> BY_VALUE_THEN_DIM = new Comparator<FacetResult>() {
|
||||
@Override
|
||||
public int compare(FacetResult a, FacetResult b) {
|
||||
if (a.value.doubleValue() > b.value.doubleValue()) {
|
||||
return -1;
|
||||
} else if (b.value.doubleValue() > a.value.doubleValue()) {
|
||||
return 1;
|
||||
} else {
|
||||
return a.dim.compareTo(b.dim);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
protected final String indexFieldName;
|
||||
protected final TaxonomyReader taxoReader;
|
||||
protected final FacetsConfig config;
|
||||
|
@ -67,20 +82,9 @@ public abstract class TaxonomyFacets extends Facets {
|
|||
ord = siblings[ord];
|
||||
}
|
||||
|
||||
// Sort by highest value, tie break by value:
|
||||
Collections.sort(results,
|
||||
new Comparator<FacetResult>() {
|
||||
@Override
|
||||
public int compare(FacetResult a, FacetResult b) {
|
||||
if (a.value.doubleValue() > b.value.doubleValue()) {
|
||||
return -1;
|
||||
} else if (b.value.doubleValue() > a.value.doubleValue()) {
|
||||
return 1;
|
||||
} else {
|
||||
return a.dim.compareTo(b.dim);
|
||||
}
|
||||
}
|
||||
});
|
||||
// Sort by highest value, tie break by dim:
|
||||
Collections.sort(results, BY_VALUE_THEN_DIM);
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
|
@ -25,8 +25,9 @@ import java.util.Comparator;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyFacetCounts;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.apache.lucene.document.Document;
|
|||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.facet.DrillSideways.DrillSidewaysResult;
|
||||
import org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetField;
|
||||
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
@ -624,7 +626,6 @@ public class TestDrillSideways extends FacetTestCase {
|
|||
|
||||
for(int dim=0;dim<numDims;dim++) {
|
||||
if (drillDowns[dim] != null) {
|
||||
int upto = 0;
|
||||
for(String value : drillDowns[dim]) {
|
||||
ddq.add("dim" + dim, value);
|
||||
}
|
||||
|
@ -786,6 +787,7 @@ public class TestDrillSideways extends FacetTestCase {
|
|||
List<Doc> hits;
|
||||
int[][] counts;
|
||||
int[] uniqueCounts;
|
||||
public TestFacetResult() {}
|
||||
}
|
||||
|
||||
private int[] getTopNOrds(final int[] counts, final String[] values, int topN) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.range;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -29,7 +29,21 @@ import org.apache.lucene.document.FloatDocValuesField;
|
|||
import org.apache.lucene.document.FloatField;
|
||||
import org.apache.lucene.document.LongField;
|
||||
import org.apache.lucene.document.NumericDocValuesField;
|
||||
import org.apache.lucene.facet.DrillDownQuery;
|
||||
import org.apache.lucene.facet.DrillSideways;
|
||||
import org.apache.lucene.facet.FacetField;
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.FacetTestCase;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.LabelAndValue;
|
||||
import org.apache.lucene.facet.MultiFacets;
|
||||
import org.apache.lucene.facet.DrillSideways.DrillSidewaysResult;
|
||||
import org.apache.lucene.facet.range.DoubleRange;
|
||||
import org.apache.lucene.facet.range.DoubleRangeFacetCounts;
|
||||
import org.apache.lucene.facet.range.LongRange;
|
||||
import org.apache.lucene.facet.range.LongRangeFacetCounts;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
@ -89,6 +103,7 @@ public class TestRangeFacetCounts extends FacetTestCase {
|
|||
d.close();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void testUselessRange() {
|
||||
try {
|
||||
new LongRange("useless", 7, true, 6, true);
|
||||
|
@ -748,9 +763,11 @@ public class TestRangeFacetCounts extends FacetTestCase {
|
|||
writer.forceMerge(1);
|
||||
|
||||
ValueSource vs = new ValueSource() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public FunctionValues getValues(Map ignored, AtomicReaderContext ignored2) {
|
||||
return new DoubleDocValues(null) {
|
||||
@Override
|
||||
public double doubleVal(int doc) {
|
||||
return doc+1;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.sortedset;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -24,6 +24,13 @@ import java.util.Map;
|
|||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.facet.DrillDownQuery;
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.FacetTestCase;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.LabelAndValue;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
import org.apache.lucene.index.SlowCompositeReaderWrapper;
|
||||
|
@ -89,6 +96,7 @@ public class TestSortedSetDocValuesFacets extends FacetTestCase {
|
|||
}
|
||||
|
||||
// LUCENE-5090
|
||||
@SuppressWarnings("unused")
|
||||
public void testStaleState() throws Exception {
|
||||
assumeTrue("Test requires SortedSetDV support", defaultCodecSupportsSortedSet());
|
||||
Directory dir = newDirectory();
|
||||
|
@ -296,7 +304,7 @@ public class TestSortedSetDocValuesFacets extends FacetTestCase {
|
|||
System.out.println("\nTEST: iter content=" + searchToken);
|
||||
}
|
||||
FacetsCollector fc = new FacetsCollector();
|
||||
TopDocs hits = FacetsCollector.search(searcher, new TermQuery(new Term("content", searchToken)), 10, fc);
|
||||
FacetsCollector.search(searcher, new TermQuery(new Term("content", searchToken)), 10, fc);
|
||||
Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
|
||||
|
||||
// Slow, yet hopefully bug-free, faceting:
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -26,7 +26,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.facet.SearcherTaxonomyManager.SearcherAndTaxonomy;
|
||||
import org.apache.lucene.facet.FacetField;
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.FacetTestCase;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.taxonomy.SearcherTaxonomyManager;
|
||||
import org.apache.lucene.facet.taxonomy.SearcherTaxonomyManager.SearcherAndTaxonomy;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
|
@ -125,8 +132,6 @@ public class TestSearcherTaxonomyManager extends FacetTestCase {
|
|||
SearcherAndTaxonomy pair = mgr.acquire();
|
||||
try {
|
||||
//System.out.println("search maxOrd=" + pair.taxonomyReader.getSize());
|
||||
int topN = _TestUtil.nextInt(random(), 1, 20);
|
||||
|
||||
FacetsCollector sfc = new FacetsCollector();
|
||||
pair.searcher.search(new MatchAllDocsQuery(), sfc);
|
||||
Facets facets = getTaxonomyFacetCounts(pair.taxonomyReader, config, sfc);
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -19,6 +19,14 @@ package org.apache.lucene.facet;
|
|||
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.facet.FacetTestCase;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.taxonomy.FloatAssociationFacetField;
|
||||
import org.apache.lucene.facet.taxonomy.IntAssociationFacetField;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyFacetSumFloatAssociations;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyFacetSumIntAssociations;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -30,9 +30,17 @@ import org.apache.lucene.analysis.MockAnalyzer;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.facet.taxonomy.PrintTaxonomyStats;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.CachedOrdinalsReader;
|
||||
import org.apache.lucene.facet.DocValuesOrdinalsReader;
|
||||
import org.apache.lucene.facet.DrillDownQuery;
|
||||
import org.apache.lucene.facet.FacetField;
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.FacetTestCase;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.LabelAndValue;
|
||||
import org.apache.lucene.facet.OrdinalsReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
|
@ -45,7 +53,6 @@ import org.apache.lucene.search.IndexSearcher;
|
|||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.search.similarities.DefaultSimilarity;
|
||||
import org.apache.lucene.search.similarities.PerFieldSimilarityWrapper;
|
||||
import org.apache.lucene.search.similarities.Similarity;
|
||||
|
@ -700,7 +707,7 @@ public class TestTaxonomyFacetCounts extends FacetTestCase {
|
|||
System.out.println("\nTEST: iter content=" + searchToken);
|
||||
}
|
||||
FacetsCollector fc = new FacetsCollector();
|
||||
TopDocs hits = FacetsCollector.search(searcher, new TermQuery(new Term("content", searchToken)), 10, fc);
|
||||
FacetsCollector.search(searcher, new TermQuery(new Term("content", searchToken)), 10, fc);
|
||||
Facets facets = getTaxonomyFacetCounts(tr, config, fc);
|
||||
|
||||
// Slow, yet hopefully bug-free, faceting:
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -30,6 +30,13 @@ import org.apache.lucene.analysis.MockAnalyzer;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field.Store;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.facet.FacetField;
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.FacetTestCase;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.LabelAndValue;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet;
|
||||
package org.apache.lucene.facet.taxonomy;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -25,13 +25,19 @@ import java.util.Map;
|
|||
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.DoubleDocValuesField;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FloatDocValuesField;
|
||||
import org.apache.lucene.document.IntField;
|
||||
import org.apache.lucene.document.NumericDocValuesField;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.DocValuesOrdinalsReader;
|
||||
import org.apache.lucene.facet.FacetField;
|
||||
import org.apache.lucene.facet.FacetResult;
|
||||
import org.apache.lucene.facet.FacetTestCase;
|
||||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.LabelAndValue;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
|
@ -44,7 +50,6 @@ import org.apache.lucene.queries.function.FunctionQuery;
|
|||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
|
||||
import org.apache.lucene.queries.function.valuesource.DoubleFieldSource;
|
||||
import org.apache.lucene.queries.function.valuesource.FloatFieldSource;
|
||||
import org.apache.lucene.queries.function.valuesource.IntFieldSource;
|
||||
import org.apache.lucene.queries.function.valuesource.LongFieldSource;
|
||||
|
@ -55,7 +60,6 @@ import org.apache.lucene.search.Query;
|
|||
import org.apache.lucene.search.Scorer;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.search.TopScoreDocCollector;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
|
@ -345,7 +349,6 @@ public class TestTaxonomyFacetSumValueSource extends FacetTestCase {
|
|||
};
|
||||
|
||||
FacetsCollector fc = new FacetsCollector(true);
|
||||
TopScoreDocCollector tsdc = TopScoreDocCollector.create(10, true);
|
||||
// score documents by their 'price' field - makes asserting the correct counts for the categories easier
|
||||
Query q = new FunctionQuery(new LongFieldSource("price"));
|
||||
FacetsCollector.search(newSearcher(r), q, 10, fc);
|
||||
|
@ -407,13 +410,12 @@ public class TestTaxonomyFacetSumValueSource extends FacetTestCase {
|
|||
DirectoryTaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);
|
||||
|
||||
FacetsCollector fc = new FacetsCollector(true);
|
||||
TopDocs hits = FacetsCollector.search(newSearcher(r), new MatchAllDocsQuery(), 10, fc);
|
||||
FacetsCollector.search(newSearcher(r), new MatchAllDocsQuery(), 10, fc);
|
||||
|
||||
Facets facets1 = getTaxonomyFacetCounts(taxoReader, config, fc);
|
||||
Facets facets2 = new TaxonomyFacetSumValueSource(new DocValuesOrdinalsReader("$b"), taxoReader, config, fc, new TaxonomyFacetSumValueSource.ScoreValueSource());
|
||||
|
||||
assertEquals(r.maxDoc(), facets1.getTopChildren(10, "a").value.intValue());
|
||||
double expected = hits.getMaxScore() * r.numDocs();
|
||||
assertEquals(r.maxDoc(), facets2.getTopChildren(10, "b").value.doubleValue(), 1E-10);
|
||||
IOUtils.close(taxoWriter, iw, taxoReader, taxoDir, r, indexDir);
|
||||
}
|
||||
|
@ -457,7 +459,7 @@ public class TestTaxonomyFacetSumValueSource extends FacetTestCase {
|
|||
System.out.println("\nTEST: iter content=" + searchToken);
|
||||
}
|
||||
FacetsCollector fc = new FacetsCollector();
|
||||
TopDocs hits = FacetsCollector.search(searcher, new TermQuery(new Term("content", searchToken)), 10, fc);
|
||||
FacetsCollector.search(searcher, new TermQuery(new Term("content", searchToken)), 10, fc);
|
||||
Facets facets = new TaxonomyFacetSumValueSource(tr, config, fc, values);
|
||||
|
||||
// Slow, yet hopefully bug-free, faceting:
|
|
@ -32,7 +32,7 @@ import org.apache.lucene.facet.FacetResult;
|
|||
import org.apache.lucene.facet.Facets;
|
||||
import org.apache.lucene.facet.FacetsCollector;
|
||||
import org.apache.lucene.facet.FacetsConfig;
|
||||
import org.apache.lucene.facet.FastTaxonomyFacetCounts;
|
||||
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
|
|
Loading…
Reference in New Issue