mirror of
https://github.com/apache/lucene.git
synced 2025-02-20 17:07:09 +00:00
SOLR-2436: fix mapping definition
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1100435 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3a0d3e01bd
commit
1a45ff9817
@ -68,12 +68,17 @@ public class SolrUIMAConfigurationReader {
|
||||
NamedList fieldMappings = (NamedList) args.get("fieldMappings");
|
||||
/* iterate over UIMA types */
|
||||
for (int i = 0; i < fieldMappings.size(); i++) {
|
||||
NamedList mapping = (NamedList) fieldMappings.get("mapping", i);
|
||||
String typeName = (String) mapping.get("type");
|
||||
String featureName = (String) mapping.get("feature");
|
||||
String mappedFieldName = (String) mapping.get("field");
|
||||
NamedList type = (NamedList) fieldMappings.get("type", i);
|
||||
String typeName = (String)type.get("name");
|
||||
|
||||
Map<String, String> subMap = new HashMap<String, String>();
|
||||
subMap.put(featureName, mappedFieldName);
|
||||
/* iterate over mapping definitions */
|
||||
for(int j = 0; j < type.size() - 1; j++){
|
||||
NamedList mapping = (NamedList) type.get("mapping", j + 1);
|
||||
String featureName = (String) mapping.get("feature");
|
||||
String mappedFieldName = (String) mapping.get("field");
|
||||
subMap.put(featureName, mappedFieldName);
|
||||
}
|
||||
map.put(typeName, subMap);
|
||||
}
|
||||
return map;
|
||||
|
@ -39,7 +39,7 @@ import org.apache.uima.resource.ResourceInitializationException;
|
||||
*/
|
||||
public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
|
||||
|
||||
private SolrUIMAConfiguration solrUIMAConfiguration;
|
||||
SolrUIMAConfiguration solrUIMAConfiguration;
|
||||
|
||||
private AEProvider aeProvider;
|
||||
|
||||
|
@ -33,6 +33,7 @@ import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.handler.XmlUpdateRequestHandler;
|
||||
import org.apache.solr.request.SolrQueryRequestBase;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.update.processor.UpdateRequestProcessor;
|
||||
import org.apache.solr.update.processor.UpdateRequestProcessorChain;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
@ -66,6 +67,26 @@ public class UIMAUpdateRequestProcessorTest extends SolrTestCaseJ4 {
|
||||
UIMAUpdateRequestProcessorFactory factory = (UIMAUpdateRequestProcessorFactory) chained
|
||||
.getFactories()[0];
|
||||
assertNotNull(factory);
|
||||
UpdateRequestProcessor processor = factory.getInstance(req(), null, null);
|
||||
assertTrue(processor instanceof UIMAUpdateRequestProcessor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiMap() {
|
||||
SolrCore core = h.getCore();
|
||||
UpdateRequestProcessorChain chained = core.getUpdateProcessingChain("uima-multi-map");
|
||||
assertNotNull(chained);
|
||||
UIMAUpdateRequestProcessorFactory factory = (UIMAUpdateRequestProcessorFactory) chained
|
||||
.getFactories()[0];
|
||||
assertNotNull(factory);
|
||||
UpdateRequestProcessor processor = factory.getInstance(req(), null, null);
|
||||
assertTrue(processor instanceof UIMAUpdateRequestProcessor);
|
||||
SolrUIMAConfiguration conf = ((UIMAUpdateRequestProcessor)processor).solrUIMAConfiguration;
|
||||
Map<String, Map<String, String>> map = conf.getTypesFeaturesFieldsMapping();
|
||||
Map<String, String> subMap = map.get("a-type-which-can-have-multiple-features");
|
||||
assertEquals(2, subMap.size());
|
||||
assertEquals("1", subMap.get("A"));
|
||||
assertEquals("2", subMap.get("B"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -978,20 +978,26 @@
|
||||
</arr>
|
||||
</lst>
|
||||
<lst name="fieldMappings">
|
||||
<lst name="mapping">
|
||||
<str name="type">org.apache.uima.SentenceAnnotation</str>
|
||||
<str name="feature">coveredText</str>
|
||||
<str name="field">sentence</str>
|
||||
<lst name="type">
|
||||
<str name="name">org.apache.uima.SentenceAnnotation</str>
|
||||
<lst name="mapping">
|
||||
<str name="feature">coveredText</str>
|
||||
<str name="field">sentence</str>
|
||||
</lst>
|
||||
</lst>
|
||||
<lst name="mapping">
|
||||
<str name="type">org.apache.solr.uima.ts.SentimentAnnotation</str>
|
||||
<str name="feature">mood</str>
|
||||
<str name="field">sentiment</str>
|
||||
<lst name="type">
|
||||
<str name="name">org.apache.solr.uima.ts.SentimentAnnotation</str>
|
||||
<lst name="mapping">
|
||||
<str name="feature">mood</str>
|
||||
<str name="field">sentiment</str>
|
||||
</lst>
|
||||
</lst>
|
||||
<lst name="mapping">
|
||||
<str name="type">org.apache.solr.uima.ts.EntityAnnotation</str>
|
||||
<str name="feature">coveredText</str>
|
||||
<str name="field">entity</str>
|
||||
<lst name="type">
|
||||
<str name="name">org.apache.solr.uima.ts.EntityAnnotation</str>
|
||||
<lst name="mapping">
|
||||
<str name="feature">coveredText</str>
|
||||
<str name="field">entity</str>
|
||||
</lst>
|
||||
</lst>
|
||||
</lst>
|
||||
</lst>
|
||||
@ -1000,6 +1006,36 @@
|
||||
<processor class="solr.RunUpdateProcessorFactory" />
|
||||
</updateRequestProcessorChain>
|
||||
|
||||
<updateRequestProcessorChain name="uima-multi-map">
|
||||
<processor class="org.apache.solr.uima.processor.UIMAUpdateRequestProcessorFactory">
|
||||
<lst name="uimaConfig">
|
||||
<lst name="runtimeParameters">
|
||||
<int name="ngramsize">3</int>
|
||||
</lst>
|
||||
<str name="analysisEngine">/TestAE.xml</str>
|
||||
<lst name="analyzeFields">
|
||||
<bool name="merge">false</bool>
|
||||
<arr name="fields">
|
||||
<str>text</str>
|
||||
</arr>
|
||||
</lst>
|
||||
<lst name="fieldMappings">
|
||||
<lst name="type">
|
||||
<str name="name">a-type-which-can-have-multiple-features</str>
|
||||
<lst name="mapping">
|
||||
<str name="feature">A</str>
|
||||
<str name="field">1</str>
|
||||
</lst>
|
||||
<lst name="mapping">
|
||||
<str name="feature">B</str>
|
||||
<str name="field">2</str>
|
||||
</lst>
|
||||
</lst>
|
||||
</lst>
|
||||
</lst>
|
||||
</processor>
|
||||
</updateRequestProcessorChain>
|
||||
|
||||
<!--
|
||||
queryResponseWriter plugins... query responses will be written using
|
||||
the writer specified by the 'wt' request parameter matching the name
|
||||
|
Loading…
x
Reference in New Issue
Block a user