SOLR-6501: Binary Response Writer does not return wildcard fields

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1624370 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2014-09-11 19:40:04 +00:00
parent 1ba5ad4672
commit 34a47e66ca
3 changed files with 62 additions and 1 deletions

View File

@ -194,6 +194,9 @@ Bug Fixes
* SOLR-6499: Log warning about multiple update request handlers
(Noble Paul, Andreas Hubold, hossman)
* SOLR-6501: Binary Response Writer does not return wildcard fields.
(Mike Hugo, Constantin Mitocaru, sarowe, shalin)
Other Changes
---------------------

View File

@ -142,7 +142,7 @@ public class BinaryResponseWriter implements BinaryQueryResponseWriter {
}
Set<String> fnames = returnFields.getLuceneFieldNames();
boolean onlyPseudoFields = (fnames == null && !returnFields.wantsAllFields())
boolean onlyPseudoFields = (fnames == null && !returnFields.wantsAllFields() && !returnFields.hasPatternMatching())
|| (fnames != null && fnames.size() == 1 && SolrReturnFields.SCORE.equals(fnames.iterator().next()));
context.iterator = ids.iterator();
for (int i = 0; i < sz; i++) {

View File

@ -1396,6 +1396,64 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
}
}
@Test
public void testFieldGlobbing() throws Exception {
SolrServer server = getSolrServer();
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", "testFieldGlobbing");
doc.addField("x_s", "x");
doc.addField("y_s", "y");
doc.addField("z_s", "z");
server.add(doc);
server.commit();
// id and glob
QueryResponse response = server.query(new SolrQuery("id:testFieldGlobbing").addField("id").addField("*_s"));
assertEquals("Document not found", 1, response.getResults().getNumFound());
assertEquals("All requested fields were not returned", 4, response.getResults().get(0).getFieldNames().size());
// just globs
response = server.query(new SolrQuery("id:testFieldGlobbing").addField("*_s"));
assertEquals("Document not found", 1, response.getResults().getNumFound());
assertEquals("All requested fields were not returned", 3, response.getResults().get(0).getFieldNames().size());
// just id
response = server.query(new SolrQuery("id:testFieldGlobbing").addField("id"));
assertEquals("Document not found", 1, response.getResults().getNumFound());
assertEquals("All requested fields were not returned", 1, response.getResults().get(0).getFieldNames().size());
// id and pseudo field and glob
response = server.query(new SolrQuery("id:testFieldGlobbing").addField("id").addField("[docid]").addField("*_s"));
assertEquals("Document not found", 1, response.getResults().getNumFound());
assertEquals("All requested fields were not returned", 5, response.getResults().get(0).getFieldNames().size());
// pseudo field and glob
response = server.query(new SolrQuery("id:testFieldGlobbing").addField("[docid]").addField("*_s"));
assertEquals("Document not found", 1, response.getResults().getNumFound());
assertEquals("All requested fields were not returned", 4, response.getResults().get(0).getFieldNames().size());
// just a pseudo field
response = server.query(new SolrQuery("id:testFieldGlobbing").addField("[docid]"));
assertEquals("Document not found", 1, response.getResults().getNumFound());
assertEquals("All requested fields were not returned", 1, response.getResults().get(0).getFieldNames().size());
// only score
response = server.query(new SolrQuery("id:testFieldGlobbing").addField("score"));
assertEquals("Document not found", 1, response.getResults().getNumFound());
assertEquals("All requested fields were not returned", 1, response.getResults().get(0).getFieldNames().size());
// pseudo field and score
response = server.query(new SolrQuery("id:testFieldGlobbing").addField("score").addField("[docid]"));
assertEquals("Document not found", 1, response.getResults().getNumFound());
assertEquals("All requested fields were not returned", 2, response.getResults().get(0).getFieldNames().size());
// score and globs
response = server.query(new SolrQuery("id:testFieldGlobbing").addField("score").addField("*_s"));
assertEquals("Document not found", 1, response.getResults().getNumFound());
assertEquals("All requested fields were not returned", 4, response.getResults().get(0).getFieldNames().size());
}
/**
* Depth first search of a SolrInputDocument looking for a decendent by id,
* returns null if it's not a decendent