mirror of https://github.com/apache/lucene.git
SOLR-9666: SolrJ LukeResponse support dynamic fields
This commit is contained in:
parent
6c3c6bc379
commit
782923b894
|
@ -116,6 +116,8 @@ New Features
|
|||
* SOLR-9633: Limit memory consumed by FastLRUCache with a new 'maxRamMB' config parameter.
|
||||
(yonik, Michael Sun, shalin)
|
||||
|
||||
* SOLR-9666: SolrJ LukeResponse support dynamic fields (Fengtan via Kevin Risden)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
* SOLR-9704: Facet Module / JSON Facet API: Optimize blockChildren facets that have
|
||||
|
|
|
@ -42,6 +42,7 @@ public class LukeResponse extends SolrResponseBase {
|
|||
boolean tokenized;
|
||||
String analyzer;
|
||||
List<String> fields;
|
||||
List<String> dynamicFields;
|
||||
|
||||
|
||||
public FieldTypeInfo(String name) {
|
||||
|
@ -62,6 +63,10 @@ public class LukeResponse extends SolrResponseBase {
|
|||
return fields;
|
||||
}
|
||||
|
||||
public List<String> getDynamicFields() {
|
||||
return dynamicFields;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -96,6 +101,9 @@ public class LukeResponse extends SolrResponseBase {
|
|||
if ("fields".equals(key) && entry.getValue() != null) {
|
||||
List<String> theFields = (List<String>) entry.getValue();
|
||||
fields = new ArrayList<>(theFields);
|
||||
} else if ("dynamicFields".equals(key) && entry.getValue() != null) {
|
||||
List<String> theDynamicFields = (List<String>) entry.getValue();
|
||||
dynamicFields = new ArrayList<>(theDynamicFields);
|
||||
} else if ("tokenized".equals(key) == true) {
|
||||
tokenized = Boolean.parseBoolean(entry.getValue().toString());
|
||||
} else if ("analyzer".equals(key) == true) {
|
||||
|
@ -194,6 +202,7 @@ public class LukeResponse extends SolrResponseBase {
|
|||
|
||||
private NamedList<Object> indexInfo;
|
||||
private Map<String, FieldInfo> fieldInfo;
|
||||
private Map<String, FieldInfo> dynamicFieldInfo;
|
||||
private Map<String, FieldTypeInfo> fieldTypeInfo;
|
||||
|
||||
@Override
|
||||
|
@ -206,6 +215,8 @@ public class LukeResponse extends SolrResponseBase {
|
|||
|
||||
NamedList<Object> schema = (NamedList<Object>) res.get("schema");
|
||||
NamedList<Object> flds = (NamedList<Object>) res.get("fields");
|
||||
NamedList<Object> dynamicFlds = (NamedList<Object>) res.get("dynamicFields");
|
||||
|
||||
if (flds == null && schema != null ) {
|
||||
flds = (NamedList<Object>) schema.get("fields");
|
||||
}
|
||||
|
@ -218,6 +229,18 @@ public class LukeResponse extends SolrResponseBase {
|
|||
}
|
||||
}
|
||||
|
||||
if (dynamicFlds == null && schema != null) {
|
||||
dynamicFlds = (NamedList<Object>) schema.get("dynamicFields");
|
||||
}
|
||||
if (dynamicFlds != null) {
|
||||
dynamicFieldInfo = new HashMap<>();
|
||||
for (Map.Entry<String, Object> dynamicField : dynamicFlds) {
|
||||
FieldInfo f = new FieldInfo(dynamicField.getKey());
|
||||
f.read((NamedList<Object>) dynamicField.getValue());
|
||||
dynamicFieldInfo.put(dynamicField.getKey(), f);
|
||||
}
|
||||
}
|
||||
|
||||
if( schema != null ) {
|
||||
NamedList<Object> fldTypes = (NamedList<Object>) schema.get("types");
|
||||
if (fldTypes != null) {
|
||||
|
@ -274,5 +297,13 @@ public class LukeResponse extends SolrResponseBase {
|
|||
return fieldInfo.get(f);
|
||||
}
|
||||
|
||||
public Map<String, FieldInfo> getDynamicFieldInfo() {
|
||||
return dynamicFieldInfo;
|
||||
}
|
||||
|
||||
public FieldInfo getDynamicFieldInfo(String f) {
|
||||
return dynamicFieldInfo.get(f);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
}
|
||||
|
|
|
@ -694,13 +694,14 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
|
|||
luke.setShowSchema( false );
|
||||
LukeResponse rsp = luke.process( client );
|
||||
assertNull( rsp.getFieldTypeInfo() ); // if you don't ask for it, the schema is null
|
||||
assertNull( rsp.getDynamicFieldInfo() );
|
||||
|
||||
luke.setShowSchema( true );
|
||||
rsp = luke.process( client );
|
||||
assertNotNull( rsp.getFieldTypeInfo() );
|
||||
assertNotNull(rsp.getFieldInfo().get("id").getSchemaFlags());
|
||||
assertTrue(rsp.getFieldInfo().get("id").getSchemaFlags().contains(FieldFlag.INDEXED));
|
||||
|
||||
assertNotNull( rsp.getDynamicFieldInfo() );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue