Exemplo n.º 1
0
  public Collection<SolrInputDocument> getDocuments(
      RepositorySession repositorySession, Event event) {
    String topic = event.getTopic();
    if (topic.endsWith(StoreListener.UPDATED_TOPIC) || topic.endsWith(StoreListener.ADDED_TOPIC)) {
      String path = (String) event.getProperty(FIELD_PATH);

      if (!ignore(path) && !ignoreCache.containsKey(path)) {
        IndexingHandler handler =
            getHandler(repositorySession, path, this.indexers, this.ignoreCache);

        List<SolrInputDocument> outputDocs = Lists.newArrayList();
        Collection<SolrInputDocument> docs = handler.getDocuments(repositorySession, event);
        for (SolrInputDocument doc : docs) {
          // check the fields of the returned docs to make sure they contain atleast 1
          // field that is not a system property. this is not to filter out any system
          // properties but to make sure there are more things to index than just system
          // properties.
          if (!SYSTEM_PROPERTIES.containsAll(doc.getFieldNames())) {
            try {
              addDefaultFields(doc, repositorySession);
              outputDocs.add(doc);
            } catch (StorageClientException e) {
              LOGGER.warn("Failed to index {} cause: {} ", path, e.getMessage());
            }
          }
          return outputDocs;
        }
      } else {
        LOGGER.debug("Ignored action at path:{}  require on {} ", path, event);
      }
    } else {
      LOGGER.debug("No update action require on {} ", event);
    }
    return ImmutableList.of();
  }
 public Collection<String> getDeleteQueries(RepositorySession repositorySession, Event event) {
   String topic = event.getTopic();
   if (topic.endsWith(StoreListener.DELETE_TOPIC)) {
     final IndexingHandler indexingHandler = getHandler(repositorySession, event);
     if (indexingHandler != null) {
       return indexingHandler.getDeleteQueries(repositorySession, event);
     }
   } else {
     LOGGER.debug("No delete action require on {} ", event);
   }
   return ImmutableList.of();
 }
 public Collection<SolrInputDocument> getDocuments(
     RepositorySession repositorySession, Event event) {
   String topic = event.getTopic();
   if (topic.endsWith(StoreListener.UPDATED_TOPIC) || topic.endsWith(StoreListener.ADDED_TOPIC)) {
     final IndexingHandler indexingHandler = getHandler(repositorySession, event);
     if (indexingHandler != null) {
       LOGGER.debug(
           "Update action at path:{}  require on {} ", event.getProperty(FIELD_PATH), event);
       Collection<SolrInputDocument> docs = indexingHandler.getDocuments(repositorySession, event);
       List<SolrInputDocument> outputDocs = Lists.newArrayList();
       if (docs != null) {
         for (SolrInputDocument doc : docs) {
           boolean docAdded = false;
           for (String name : doc.getFieldNames()) {
             // loop through the fields of the returned docs to make sure they contain
             // atleast 1 field that is not a system property. this is not to filter out
             // any system properties but to make sure there are more things to index than
             // just system properties.
             if (!SYSTEM_PROPERTIES.contains(name)) {
               try {
                 addDefaultFields(doc, repositorySession);
                 outputDocs.add(doc);
                 docAdded = true;
               } catch (StorageClientException e) {
                 LOGGER.warn(
                     "Failed to index {} cause: {} ",
                     event.getProperty(FIELD_PATH),
                     e.getMessage());
               }
               break;
             }
           }
           if (!docAdded) {
             TelemetryCounter.incrementValue(
                 "solr", "SparseIndexingServiceImpl", "docHasOnlySysProps");
           }
         }
       }
       return outputDocs;
     } else {
       LOGGER.debug(
           "Ignored action at path:{}  require on {} ", event.getProperty(FIELD_PATH), event);
     }
   } else {
     LOGGER.debug("No update action require on {} ", event);
   }
   return ImmutableList.of();
 }
Exemplo n.º 4
0
  public Collection<String> getDeleteQueries(RepositorySession repositorySession, Event event) {
    String topic = event.getTopic();
    if (topic.endsWith(StoreListener.DELETE_TOPIC)) {
      String path = (String) event.getProperty(FIELD_PATH);
      if (!ignore(path) && !ignoreCache.containsKey(path)) {
        String resourceType = (String) event.getProperty("resourceType");

        IndexingHandler handler = null;
        if (resourceType != null) {
          handler = getHandler(resourceType, this.indexers);
        } else {
          handler = getHandler(repositorySession, path, this.indexers, this.ignoreCache);
        }
        return handler.getDeleteQueries(repositorySession, event);
      }
    } else {
      LOGGER.debug("No delete action require on {} ", event);
    }
    return ImmutableList.of();
  }
 public void removeHandler(String key, IndexingHandler handler) {
   if (handler.equals(indexers.get(key))) {
     indexers.remove(key);
   }
 }