mirror of https://github.com/apache/lucene.git
SOLR-929: LukeRequestHandler should return "dynamicBase" only if the field is dynamic.
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@771270 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
44302daeb2
commit
01b26e52cf
|
@ -356,6 +356,9 @@ Bug Fixes
|
|||
|
||||
42. SOLR-1138: Query Elevation Component now gracefully handles missing queries. (gsingers)
|
||||
|
||||
43. SOLR-929: LukeRequestHandler should return "dynamicBase" only if the field is dynamic.
|
||||
(Peter Wolanin, koji)
|
||||
|
||||
Other Changes
|
||||
----------------------
|
||||
1. Upgraded to Lucene 2.4.0 (yonik)
|
||||
|
|
|
@ -300,7 +300,7 @@ public class LukeRequestHandler extends RequestHandlerBase
|
|||
|
||||
f.add( "type", (ftype==null)?null:ftype.getTypeName() );
|
||||
f.add( "schema", getFieldFlags( sfield ) );
|
||||
if (sfield != null && schema.getDynamicPattern(sfield.getName()) != null) {
|
||||
if (sfield != null && schema.isDynamicField(sfield.getName()) && schema.getDynamicPattern(sfield.getName()) != null) {
|
||||
f.add("dynamicBase", schema.getDynamicPattern(sfield.getName()));
|
||||
}
|
||||
|
||||
|
|
|
@ -1013,6 +1013,23 @@ public final class IndexSchema {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the specified field dynamic or not.
|
||||
* @param fieldName
|
||||
* @return true if the specified field is dynamic
|
||||
*/
|
||||
public boolean isDynamicField(String fieldName) {
|
||||
if(fields.containsKey(fieldName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DynamicField df : dynamicFields) {
|
||||
if (df.matches(fieldName)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SchemaField that should be used for the specified field name, or
|
||||
* null if none exists.
|
||||
|
|
|
@ -129,4 +129,12 @@ public class IndexSchemaTest extends AbstractSolrTestCase {
|
|||
,"//result/doc[1]/int[@name='id'][.='10']"
|
||||
);
|
||||
}
|
||||
|
||||
public void testIsDynamicField() throws Exception {
|
||||
SolrCore core = h.getCore();
|
||||
IndexSchema schema = core.getSchema();
|
||||
assertFalse( schema.isDynamicField( "id" ) );
|
||||
assertTrue( schema.isDynamicField( "aaa_i" ) );
|
||||
assertFalse( schema.isDynamicField( "no_such_field" ) );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue