当前位置: 首页>>代码示例>>Java>>正文


Java AddUpdateCommand.getSolrInputDocument方法代码示例

本文整理汇总了Java中org.apache.solr.update.AddUpdateCommand.getSolrInputDocument方法的典型用法代码示例。如果您正苦于以下问题:Java AddUpdateCommand.getSolrInputDocument方法的具体用法?Java AddUpdateCommand.getSolrInputDocument怎么用?Java AddUpdateCommand.getSolrInputDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.update.AddUpdateCommand的用法示例。


在下文中一共展示了AddUpdateCommand.getSolrInputDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processAdd

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
  final SolrInputDocument doc = cmd.getSolrInputDocument();

  final String math = doc.containsKey(ttlField) 
    ? doc.getFieldValue(ttlField).toString() : defaultTtl;

  if (null != math) {
    try {
      final DateMathParser dmp = new DateMathParser();
      // TODO: should we try to accept things like "1DAY" as well as "+1DAY" ?
      // How? 
      // 'startsWith("+")' is a bad idea because it would cause porblems with
      // things like "/DAY+1YEAR"
      // Maybe catch ParseException and rety with "+" prepended?
      doc.addField(expireField, dmp.parseMath(math));
    } catch (ParseException pe) {
      throw new SolrException(BAD_REQUEST, "Can't parse ttl as date math: " + math, pe);
    }
  }

  super.processAdd(cmd);
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:DocExpirationUpdateProcessorFactory.java

示例2: processBoost

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
public void processBoost(AddUpdateCommand command) {
  SolrInputDocument document = command.getSolrInputDocument();
  if (document.containsKey(inputFieldname)) {
    String value = (String) document.getFieldValue(inputFieldname);
    double boost = 1.0f;
    for (BoostEntry boostEntry : boostEntries) {
      if (boostEntry.getPattern().matcher(value).matches()) {
        if (log.isDebugEnabled()) {
          log.debug("Pattern match " + boostEntry.getPattern().pattern() + " for " + value);
        }
        boost = (boostEntry.getBoost() * 1000) * (boost * 1000) / 1000000;
      }
    }
    document.setField(boostFieldname, boost);

    if (log.isDebugEnabled()) {
      log.debug("Value " + boost + ", applied to field " + boostFieldname);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:RegexpBoostProcessor.java

示例3: processAdd

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
@Override
public void processAdd(final AddUpdateCommand command) throws IOException  {
	final SolrInputDocument document = command.getSolrInputDocument();
	final String address = (String) document.getFieldValue("address");
	if (address != null && address.trim().length() !=  0) {
		try {
			final String id = String.valueOf(document.getFieldValue("id"));
			final String coordinates = service.getCoordinates(id, address);
			if (coordinates != null && coordinates.trim().length() != 0) {
				document.addField("coordinates", coordinates);
			} else {
				LOGGER.error("Document " + id + "  with address \"" + address+" \" hasn't been translated (null address)");
			}
		
			sleep();
		} catch (final Exception exception) {
			LOGGER.error("Unable to get coordinates for "+ document, exception);
		}
		super.processAdd(command);			
	}
}
 
开发者ID:agazzarini,项目名称:apache-solr-essentials,代码行数:22,代码来源:AddCoordinatesUpdateRequestProcessor.java

示例4: processAdd

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
/**
 * Where is where we can "interfere" with the indexing process of 
 * the document wrapped in the given command
 * 
 * If we want Solr to skip the document at all, just omit this call:
 * 
 *  super.processAdd(command);
 */
@Override
public void processAdd(AddUpdateCommand command) throws IOException {
	// Get the document that is going to be indexed
	SolrInputDocument document = command.getSolrInputDocument();
	
	// Removes the title field.
	// In a real system, the list of fields to be removed should come from the configuration.
	document.removeField("title");
	
	// This is important: if you omit this call the document will be ignored by Solr
	super.processAdd(command);
}
 
开发者ID:agazzarini,项目名称:as-full-text-search-server,代码行数:21,代码来源:RemoveFieldUpdateRequestProcessor.java

示例5: isAtomicUpdate

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
/**
 * Utility method that examines the SolrInputDocument in an AddUpdateCommand
 * and returns true if the documents contains atomic update instructions.
 */
public static boolean isAtomicUpdate(final AddUpdateCommand cmd) {
  SolrInputDocument sdoc = cmd.getSolrInputDocument();
  for (SolrInputField sif : sdoc.values()) {
    if (sif.getValue() instanceof Map) {
      return true;
    }
  }
  return false;
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:DistributedUpdateProcessor.java

示例6: getInstance

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
@Override
public final UpdateRequestProcessor getInstance(SolrQueryRequest req,
                                                SolrQueryResponse rsp,
                                                UpdateRequestProcessor next) {
  return new UpdateRequestProcessor(next) {
    @Override
    public void processAdd(AddUpdateCommand cmd) throws IOException {

      final SolrInputDocument doc = cmd.getSolrInputDocument();

      // preserve initial values and boost (if any)
      SolrInputField destField = doc.containsKey(dest) ? 
        doc.getField(dest) : new SolrInputField(dest); 
      
      boolean modified = false;
      for (final String fname : doc.getFieldNames()) {
        if (! srcSelector.shouldMutate(fname)) continue;

        for (Object val : doc.getFieldValues(fname)) {
          // preserve existing dest boost (multiplicitive), ignore src boost
          destField.addValue(val, 1.0f);
        }
        modified=true;
      }

      if (modified) doc.put(dest, destField);

      super.processAdd(cmd);
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:32,代码来源:CloneFieldUpdateProcessorFactory.java

示例7: processAdd

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
  final SolrInputDocument doc = cmd.getSolrInputDocument();

  if (! doc.containsKey(fieldName)) {
    doc.addField(fieldName, getDefaultValue());
  }

  super.processAdd(cmd);
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:AbstractDefaultValueUpdateProcessorFactory.java

示例8: processAdd

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
public void processAdd(AddUpdateCommand cmd) throws IOException {
  if (!isLeader(cmd)) {
    super.processAdd(cmd);
    return;
  }

  final SolrInputDocument newDoc = cmd.getSolrInputDocument();

  Object newVersion = newDoc.getFieldValue(versionFieldName);
  if ( null == newVersion ) {
    throw new SolrException(BAD_REQUEST, "Doc does not have versionField: " + versionFieldName);
  }

  for (int i=0; ;i++) {
    // Log a warning every 256 retries.... even a few retries should normally be very unusual.
    if ((i&0xff) == 0xff) {
      log.warn("Unusual number of optimistic concurrency retries: retries=" + i + " cmd=" + cmd);
    }

    if (!isVersionNewEnough(cmd.getIndexedId(), newVersion)) {
      // drop older update
      return;
    }

    try {
      cmd.setVersion(oldSolrVersion);  // use optimistic concurrency to ensure that the doc has not changed in the meantime
      super.processAdd(cmd);
      return;
    } catch (SolrException e) {
      if (e.code() == 409) {
        // log.info ("##################### CONFLICT ADDING newDoc=" + newDoc + " newVersion=" + newVersion );
        continue;  // if a version conflict, retry
      }
      throw e;  // rethrow
    }

  }
}
 
开发者ID:europeana,项目名称:search,代码行数:39,代码来源:DocBasedVersionConstraintsProcessorFactory.java

示例9: processAdd

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
/**
 * Calls <code>mutate</code> on any fields identified by the selector 
 * before forwarding the command down the chain.  Any SolrExceptions 
 * thrown by <code>mutate</code> will be logged with the Field name, 
 * wrapped and re-thrown.
 */
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
  final SolrInputDocument doc = cmd.getSolrInputDocument();

  // make a copy we can iterate over while mutating the doc
  final Collection<String> fieldNames 
    = new ArrayList<>(doc.getFieldNames());

  for (final String fname : fieldNames) {

    if (! selector.shouldMutate(fname)) continue;
    
    final SolrInputField src = doc.get(fname);

    SolrInputField dest = null;
    try { 
      dest = mutate(src);
    } catch (SolrException e) {
      String msg = "Unable to mutate field '"+fname+"': "+e.getMessage();
      SolrException.log(log, msg, e);
      throw new SolrException(BAD_REQUEST, msg, e);
    }
    if (null == dest) {
      doc.remove(fname);
    } else {
      // semantics of what happens if dest has diff name are hard
      // we could treat it as a copy, or a rename
      // for now, don't allow it.
      if (! fname.equals(dest.getName()) ) {
        throw new SolrException(SERVER_ERROR,
                                "mutate returned field with different name: " 
                                + fname + " => " + dest.getName());
      }
      doc.put(dest.getName(), dest);
    }
  }
  super.processAdd(cmd);
}
 
开发者ID:europeana,项目名称:search,代码行数:45,代码来源:FieldMutatingUpdateProcessor.java

示例10: processAdd

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
    SolrInputDocument doc = cmd.getSolrInputDocument();
    synchronized (esProcessor) {
        esProcessor.add(doc);
    }
    // pass it up the chain, if we want to index just in ES, it is enough to remove the RunUpdateProcessorFactory in Solr config
    super.processAdd(cmd);
}
 
开发者ID:jmlucjav,项目名称:esURP,代码行数:10,代码来源:EsUpdateRequestProcessorFactory.java

示例11: processAdd

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
    SolrInputDocument sd = cmd.getSolrInputDocument();
    //child docs
    List<SolrInputDocument> children = sd.getChildDocuments();
    if (children != null) {
        //they are ordered by from_date
        int increase = 0;
        float increasePerc = 0;
        SolrInputDocument prev = null;
        int salaryPrev = 0;
        for (SolrInputDocument d : children) {
            int salary = (int) d.getFieldValue("salary");
            if (prev != null) {
                int tinc = salary - salaryPrev;
                if (tinc > increase) {
                    increase = tinc;
                }
                float tperc = (float) tinc / (float) salaryPrev;
                if (tperc > increasePerc) {
                    increasePerc = tperc;
                }
            }
            prev = d;
            salaryPrev = salary;
        }
        sd.addField("increase", increase);
        sd.addField("increasePerc", increasePerc);
    }

    super.processAdd(cmd);
}
 
开发者ID:jmlucjav,项目名称:esURP,代码行数:33,代码来源:SalaryAnalysisProcessorFactory.java

示例12: processAdd

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
    SolrInputDocument doc = cmd.getSolrInputDocument();
    for (MultiSuggester suggester : suggesters) {
        suggester.add (doc, cmd.getReq().getSearcher());
    }
    if (next != null) {
        next.processAdd(cmd);
    }
}
 
开发者ID:safarijv,项目名称:ifpress-solr-plugin,代码行数:11,代码来源:MultiSuggesterProcessor.java

示例13: updateDocValues

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
private void updateDocValues(String keyField, String[] valueFields, AddUpdateCommand cmd) throws IOException {
  RefCounted<IndexWriter> iwref = core.getSolrCoreState().getIndexWriter(core);
  try {
    IndexWriter iw = iwref.get();
    SolrInputDocument solrInputDocument = cmd.getSolrInputDocument();
    updateDocValuesHelper(keyField, valueFields, iw, solrInputDocument);
  } finally {
    iwref.decref();
  }
}
 
开发者ID:safarijv,项目名称:ifpress-solr-plugin,代码行数:11,代码来源:UpdateDocValuesProcessor.java

示例14: processAdd

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
/**
 * Calls <code>mutate</code> on any fields identified by the selector 
 * before forwarding the command down the chain.  Any SolrExceptions 
 * thrown by <code>mutate</code> will be logged with the Field name, 
 * wrapped and re-thrown.
 */
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
  final SolrInputDocument doc = cmd.getSolrInputDocument();

  // make a copy we can iterate over while mutating the doc
  final Collection<String> fieldNames 
    = new ArrayList<String>(doc.getFieldNames());

  for (final String fname : fieldNames) {

    if (! selector.shouldMutate(fname)) continue;
    
    final SolrInputField src = doc.get(fname);

    SolrInputField dest = null;
    try { 
      dest = mutate(src);
    } catch (SolrException e) {
      String msg = "Unable to mutate field '"+fname+"': "+e.getMessage();
      SolrException.log(log, msg, e);
      throw new SolrException(BAD_REQUEST, msg, e);
    }
    if (null == dest) {
      doc.remove(fname);
    } else {
      // semantics of what happens if dest has diff name are hard
      // we could treat it as a copy, or a rename
      // for now, don't allow it.
      if (! fname.equals(dest.getName()) ) {
        throw new SolrException(SERVER_ERROR,
                                "mutute returned field with different name: " 
                                + fname + " => " + dest.getName());
      }
      doc.put(dest.getName(), dest);
    }
  }
  super.processAdd(cmd);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:45,代码来源:FieldMutatingUpdateProcessor.java

示例15: processAdd

import org.apache.solr.update.AddUpdateCommand; //导入方法依赖的package包/类
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
  String text = null;
  try {
    /* get Solr document */
    SolrInputDocument solrInputDocument = cmd.getSolrInputDocument();

    /* get the fields to analyze */
    String[] texts = getTextsToAnalyze(solrInputDocument);
    for (int i = 0; i < texts.length; i++) {
      text = texts[i];
      if (text != null && text.length()>0) {
        /* create a JCas which contain the text to analyze */
        JCas jcas = pool.getJCas(0);
        try {
          /* process the text value */
          processText(text, jcas);

          UIMAToSolrMapper uimaToSolrMapper = new UIMAToSolrMapper(
              solrInputDocument, jcas);
          /* get field mapping from config */
          Map<String,Map<String,MapField>> typesAndFeaturesFieldsMap = solrUIMAConfiguration
              .getTypesFeaturesFieldsMapping();
          /* map type features on fields */
          for (Entry<String,Map<String,MapField>> entry : typesAndFeaturesFieldsMap
              .entrySet()) {
            uimaToSolrMapper.map(entry.getKey(), entry.getValue());
          }
        } finally {
          pool.releaseJCas(jcas);
        }
      }
    }
  } catch (Exception e) {
    String logField = solrUIMAConfiguration.getLogField();
    if (logField == null) {
      SchemaField uniqueKeyField = cmd.getReq().getSchema()
          .getUniqueKeyField();
      if (uniqueKeyField != null) {
        logField = uniqueKeyField.getName();
      }
    }
    String optionalFieldInfo = logField == null ? "."
        : new StringBuilder(". ")
            .append(logField)
            .append("=")
            .append(
                (String) cmd.getSolrInputDocument().getField(logField)
                    .getValue()).append(", ").toString();
    int len;
    String debugString;
    if (text != null && text.length() > 0) {
      len = Math.min(text.length(), 100);
      debugString = new StringBuilder(" text=\"")
          .append(text.substring(0, len)).append("...\"").toString();
    } else {
      debugString = " null text";
    }
    if (solrUIMAConfiguration.isIgnoreErrors()) {
      log.warn(
          "skip the text processing due to {}",
          new StringBuilder().append(e.getLocalizedMessage())
              .append(optionalFieldInfo).append(debugString));
    } else {
      throw new SolrException(ErrorCode.SERVER_ERROR, new StringBuilder(
          "processing error ").append(e.getLocalizedMessage())
          .append(optionalFieldInfo).append(debugString).toString(), e);
    }
  }
  super.processAdd(cmd);
}
 
开发者ID:europeana,项目名称:search,代码行数:72,代码来源:UIMAUpdateRequestProcessor.java


注:本文中的org.apache.solr.update.AddUpdateCommand.getSolrInputDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。