private SolrInputDocument createDocument()

in Solrcas/src/main/java/org/apache/uima/solrcas/SolrCASConsumer.java [204:232]


  private SolrInputDocument createDocument(CAS cas) {
    SolrInputDocument document = new SolrInputDocument();
    if (mappingConfig.getDocumentTextMapping() != null && mappingConfig.getDocumentTextMapping().length() > 0)
      document.addField(mappingConfig.getDocumentTextMapping(), cas.getDocumentText());
    if (mappingConfig.getDocumentLanguageMapping() != null && mappingConfig.getDocumentLanguageMapping().length() > 0)
      document.addField(mappingConfig.getDocumentLanguageMapping(), cas.getDocumentLanguage());
    for (String key : mappingConfig.getFeatureStructuresMapping().keySet()) {
      Type type = cas.getTypeSystem().getType(key);

      for (FSIterator<FeatureStructure> iterator = cas.getIndexRepository().getAllIndexedFS(type); iterator
              .hasNext();) {
        FeatureStructure fs = iterator.next();
        Map<String, String> stringStringMap = mappingConfig.getFeatureStructuresMapping().get(key);

        for (String featureName : stringStringMap.keySet()) {
          String fieldName = stringStringMap.get(featureName);
          String featureValue;
          if (fs instanceof AnnotationFS && "coveredText".equals(featureName)) {
            featureValue = ((AnnotationFS) fs).getCoveredText();
          } else {
            Feature feature = type.getFeatureByBaseName(featureName);
            featureValue = fs.getFeatureValueAsString(feature);
          }
          document.addField(fieldName, featureValue);
        }
      }
    }
    return document;
  }