mirror of https://github.com/apache/lucene.git
SOLR-792 -- write the value as an Object, not always a string
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1024323 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
933ebe5522
commit
054df4343c
|
@ -30,6 +30,10 @@ import org.apache.solr.request.SolrQueryRequest;
|
|||
import org.apache.solr.schema.FieldType;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.document.Field.Index;
|
||||
import org.apache.lucene.document.Field.Store;
|
||||
import org.apache.lucene.index.Term;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -116,30 +120,30 @@ public class PivotFacetComponent extends SearchComponent
|
|||
{
|
||||
SolrIndexSearcher searcher = rb.req.getSearcher();
|
||||
// TODO: optimize to avoid converting to an external string and then having to convert back to internal below
|
||||
FieldType ftype = null;
|
||||
FieldType ftype = searcher.getSchema().getField(field).getType();
|
||||
|
||||
// Required to translate back to an object
|
||||
Field f = new Field( field, "X", Store.YES, Index.ANALYZED );
|
||||
|
||||
// SimpleFacets sf = getFacetImplementation(rb.req, docs, rb.req.getParams());
|
||||
String nextField = fnames.poll();
|
||||
|
||||
List<NamedList<Object>> values = new ArrayList<NamedList<Object>>( superFacets.size() );
|
||||
for (Map.Entry<String, Integer> kv : superFacets) {
|
||||
// Only sub-facet if parent facet has positive count - still may not be any values for the sub-field though
|
||||
if (kv.getValue() > minMatch ) {
|
||||
String internal = ftype.toInternal( kv.getKey() );
|
||||
f.setValue( internal );
|
||||
|
||||
SimpleOrderedMap<Object> pivot = new SimpleOrderedMap<Object>();
|
||||
pivot.add( "field", field );
|
||||
pivot.add( "value", kv.getKey() );
|
||||
pivot.add( "value", ftype.toObject( f ) );
|
||||
pivot.add( "count", kv.getValue() );
|
||||
|
||||
if( subField == null ) {
|
||||
values.add( pivot );
|
||||
}
|
||||
else {
|
||||
String s = kv.getKey();
|
||||
if( ftype == null ) {
|
||||
ftype = searcher.getSchema().getField(field).getType();
|
||||
}
|
||||
|
||||
Query query = new TermQuery(new Term(field, ftype.toInternal(s)));
|
||||
Query query = new TermQuery(new Term(field, internal));
|
||||
DocSet subset = searcher.getDocSet(query, docs);
|
||||
SimpleFacets sf = getFacetImplementation(rb.req, subset, rb.req.getParams());
|
||||
|
||||
|
|
|
@ -650,9 +650,9 @@ abstract public class SolrExampleTests extends SolrJettyTestBase
|
|||
counts = p.getPivot();
|
||||
// p.write(System.out, 5 );
|
||||
assertEquals( 1, counts.size() );
|
||||
assertEquals( "inStock", counts.get(0).getField() );
|
||||
assertEquals( "true", counts.get(0).getValue() );
|
||||
assertEquals( 2, counts.get(0).getCount() );
|
||||
assertEquals( "inStock", counts.get(0).getField() );
|
||||
assertEquals( Boolean.TRUE, counts.get(0).getValue() );
|
||||
assertEquals( 2, counts.get(0).getCount() );
|
||||
}
|
||||
|
||||
public static SolrInputDocument makeTestDoc( Object ... kvp )
|
||||
|
|
Loading…
Reference in New Issue