SOLR-9490: Fixed bugs in BoolField that caused it to erroneously return "false" for all docs depending on usage

This commit is contained in:
Chris Hostetter 2016-09-09 11:45:09 -07:00
parent c6ab0e0f1b
commit 60ce8d7c54
3 changed files with 13 additions and 6 deletions

View File

@ -119,6 +119,8 @@ Bug Fixes
* SOLR-9488: Shard split can fail to write commit data on shutdown/restart causing replicas to recover
without replicating the index. This can cause data loss. (shalin)
* SOLR-9490: Fixed bugs in BoolField that caused it to erroneously return "false" for all docs depending
on usage (Colvin Cowie, Dan Fox, hossman)
Optimizations
----------------------

View File

@ -128,11 +128,13 @@ public class BoolField extends PrimitiveFieldType {
@Override
public String toExternal(IndexableField f) {
if (f.binaryValue() == null) {
return null;
if (null != f.binaryValue()) {
return indexedToReadable(f.binaryValue().utf8ToString());
}
return indexedToReadable(f.binaryValue().utf8ToString());
if (null != f.stringValue()) {
return indexedToReadable(f.stringValue());
}
return null;
}
@Override

View File

@ -182,12 +182,15 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
// test a second query, test making a copy of the main query
SolrQuery query2 = query.getCopy();
query2.addFilterQuery("inStock:true");
Assert.assertFalse(query.getFilterQueries() == query2.getFilterQueries());
response = client.query( query2 );
Assert.assertEquals(1, query2.getFilterQueries().length);
Assert.assertEquals(0, response.getStatus());
Assert.assertEquals(2, response.getResults().getNumFound() );
Assert.assertFalse(query.getFilterQueries() == query2.getFilterQueries());
for (SolrDocument outDoc : response.getResults()) {
assertEquals(true, outDoc.getFieldValue("inStock"));
}
// sanity check round tripping of params...
query = new SolrQuery("foo");
query.addFilterQuery("{!field f=inStock}true");