mirror of https://github.com/apache/lucene.git
SOLR-7622: changed return type from array to Set
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1687307 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
33a4099b98
commit
6416f8bad3
|
@ -63,15 +63,15 @@ public abstract class DocTransformer {
|
||||||
public abstract void transform(SolrDocument doc, int docid) throws IOException;
|
public abstract void transform(SolrDocument doc, int docid) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a transformer needs access to fields that are not automaticaly derived from the
|
* When a transformer needs access to fields that are not automatically derived from the
|
||||||
* input fields names, this option lets us explicitly say the field names that we hope
|
* input fields names, this option lets us explicitly say the field names that we hope
|
||||||
* will be in the SolrDocument. These fields will be requestd from the
|
* will be in the SolrDocument. These fields will be requested from the
|
||||||
* {@link SolrIndexSearcher} but may or may not be returned in the final
|
* {@link SolrIndexSearcher} but may or may not be returned in the final
|
||||||
* {@link QueryResponseWriter}
|
* {@link QueryResponseWriter}
|
||||||
*
|
*
|
||||||
* @return a list of extra lucene fields
|
* @return a set of extra lucene fields
|
||||||
*/
|
*/
|
||||||
public String[] getExtraRequestFields() {
|
public Set<String> getExtraRequestFields() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -265,7 +265,7 @@ public class SolrReturnFields extends ReturnFields {
|
||||||
DocTransformer t = factory.create(disp, augmenterParams, req);
|
DocTransformer t = factory.create(disp, augmenterParams, req);
|
||||||
if(t!=null) {
|
if(t!=null) {
|
||||||
if(!_wantsAllFields) {
|
if(!_wantsAllFields) {
|
||||||
String[] extra = t.getExtraRequestFields();
|
Set<String> extra = t.getExtraRequestFields();
|
||||||
if(extra!=null) {
|
if(extra!=null) {
|
||||||
for(String f : extra) {
|
for(String f : extra) {
|
||||||
fields.add(f); // also request this field from IndexSearcher
|
fields.add(f); // also request this field from IndexSearcher
|
||||||
|
|
|
@ -18,7 +18,11 @@ package org.apache.solr.response;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.apache.lucene.document.StoredField;
|
import org.apache.lucene.document.StoredField;
|
||||||
import org.apache.lucene.index.IndexableField;
|
import org.apache.lucene.index.IndexableField;
|
||||||
import org.apache.lucene.index.StorableField;
|
import org.apache.lucene.index.StorableField;
|
||||||
|
@ -75,10 +79,10 @@ public class TestCustomDocTransformer extends SolrTestCaseJ4 {
|
||||||
public static class CustomTransformerFactory extends TransformerFactory {
|
public static class CustomTransformerFactory extends TransformerFactory {
|
||||||
@Override
|
@Override
|
||||||
public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {
|
public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {
|
||||||
String[] extra = null;
|
Set<String> extra = null;
|
||||||
String ext = params.get("extra");
|
String ext = params.get("extra");
|
||||||
if(ext!=null) {
|
if(ext!=null) {
|
||||||
extra = Strings.split(ext, ',');
|
extra = new HashSet<>(Arrays.asList(Strings.split(ext,',')));
|
||||||
}
|
}
|
||||||
return new CustomTransformer(field, extra);
|
return new CustomTransformer(field, extra);
|
||||||
}
|
}
|
||||||
|
@ -86,10 +90,10 @@ public class TestCustomDocTransformer extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
public static class CustomTransformer extends DocTransformer {
|
public static class CustomTransformer extends DocTransformer {
|
||||||
final String name;
|
final String name;
|
||||||
final String[] extra;
|
final Set<String> extra;
|
||||||
final StringBuilder str = new StringBuilder();
|
final StringBuilder str = new StringBuilder();
|
||||||
|
|
||||||
public CustomTransformer(String name, String[] extra) {
|
public CustomTransformer(String name, Set<String> extra) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.extra = extra;
|
this.extra = extra;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +104,7 @@ public class TestCustomDocTransformer extends SolrTestCaseJ4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getExtraRequestFields() {
|
public Set<String> getExtraRequestFields() {
|
||||||
return extra;
|
return extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue