mirror of https://github.com/apache/lucene.git
LUCENE-4802: omitNorms for facet drilldown fields
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1450299 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4f9c470dde
commit
ec2978de6d
|
@ -271,6 +271,8 @@ Bug Fixes
|
||||||
AnalysisSPILoader when doing reload (e.g. from Solr).
|
AnalysisSPILoader when doing reload (e.g. from Solr).
|
||||||
(Uwe Schindler, Hossman)
|
(Uwe Schindler, Hossman)
|
||||||
|
|
||||||
|
* LUCENE-4802: Don't compute norms for drill-down facet fields. (Mike McCandless)
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
|
|
||||||
* LUCENE-4718: Fixed documentation of oal.queryparser.classic.
|
* LUCENE-4718: Fixed documentation of oal.queryparser.classic.
|
||||||
|
|
|
@ -5,8 +5,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.lucene.document.BinaryDocValuesField;
|
import org.apache.lucene.document.BinaryDocValuesField;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
|
@ -66,6 +66,7 @@ public class FacetFields {
|
||||||
private static final FieldType DRILL_DOWN_TYPE = new FieldType(TextField.TYPE_NOT_STORED);
|
private static final FieldType DRILL_DOWN_TYPE = new FieldType(TextField.TYPE_NOT_STORED);
|
||||||
static {
|
static {
|
||||||
DRILL_DOWN_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
DRILL_DOWN_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||||
|
DRILL_DOWN_TYPE.setOmitNorms(true);
|
||||||
DRILL_DOWN_TYPE.freeze();
|
DRILL_DOWN_TYPE.freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,15 +21,19 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.lucene.analysis.MockAnalyzer;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
|
import org.apache.lucene.document.Field;
|
||||||
import org.apache.lucene.facet.FacetTestCase;
|
import org.apache.lucene.facet.FacetTestCase;
|
||||||
import org.apache.lucene.facet.FacetTestUtils;
|
import org.apache.lucene.facet.FacetTestUtils;
|
||||||
import org.apache.lucene.facet.index.FacetFields;
|
import org.apache.lucene.facet.index.FacetFields;
|
||||||
import org.apache.lucene.facet.params.FacetSearchParams;
|
import org.apache.lucene.facet.params.FacetSearchParams;
|
||||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
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.DirectoryTaxonomyReader;
|
||||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||||
import org.apache.lucene.facet.util.PrintTaxonomyStats;
|
import org.apache.lucene.facet.util.PrintTaxonomyStats;
|
||||||
|
@ -37,6 +41,9 @@ import org.apache.lucene.index.IndexWriterConfig;
|
||||||
import org.apache.lucene.index.RandomIndexWriter;
|
import org.apache.lucene.index.RandomIndexWriter;
|
||||||
import org.apache.lucene.search.IndexSearcher;
|
import org.apache.lucene.search.IndexSearcher;
|
||||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||||
|
import org.apache.lucene.search.similarities.DefaultSimilarity;
|
||||||
|
import org.apache.lucene.search.similarities.PerFieldSimilarityWrapper;
|
||||||
|
import org.apache.lucene.search.similarities.Similarity;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
|
|
||||||
public class TestDemoFacets extends FacetTestCase {
|
public class TestDemoFacets extends FacetTestCase {
|
||||||
|
@ -134,4 +141,30 @@ public class TestDemoFacets extends FacetTestCase {
|
||||||
taxoDir.close();
|
taxoDir.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testReallyNoNormsForDrillDown() throws Exception {
|
||||||
|
Directory dir = newDirectory();
|
||||||
|
Directory taxoDir = newDirectory();
|
||||||
|
IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
||||||
|
iwc.setSimilarity(new PerFieldSimilarityWrapper() {
|
||||||
|
final Similarity sim = new DefaultSimilarity();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Similarity get(String name) {
|
||||||
|
assertEquals("field", name);
|
||||||
|
return sim;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, iwc);
|
||||||
|
TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir, IndexWriterConfig.OpenMode.CREATE);
|
||||||
|
FacetFields facetFields = new FacetFields(taxoWriter);
|
||||||
|
|
||||||
|
Document doc = new Document();
|
||||||
|
doc.add(newTextField("field", "text", Field.Store.NO));
|
||||||
|
facetFields.addFields(doc, Collections.singletonList(new CategoryPath("a/path", '/')));
|
||||||
|
writer.addDocument(doc);
|
||||||
|
writer.close();
|
||||||
|
taxoWriter.close();
|
||||||
|
dir.close();
|
||||||
|
taxoDir.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue