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


Java SolrInputField.setBoost方法代码示例

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


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

示例1: mutate

import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
@Override
protected final SolrInputField mutate(final SolrInputField src) {
  SolrInputField result = new SolrInputField(src.getName());
  for (final Object srcVal : src.getValues()) {
    final Object destVal = mutateValue(srcVal);
    if (DELETE_VALUE_SINGLETON == destVal) { 
      /* NOOP */
      log.debug("removing value from field '{}': {}", 
                src.getName(), srcVal);
    } else {
      if (destVal != srcVal) {
        log.debug("replace value from field '{}': {} with {}", 
                  new Object[] { src.getName(), srcVal, destVal });
      }
      result.addValue(destVal, 1.0F);
    }
  }
  result.setBoost(src.getBoost());
  return 0 == result.getValueCount() ? null : result;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:FieldValueMutatingUpdateProcessor.java

示例2: mutate

import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
@Override
protected SolrInputField mutate(SolrInputField src) {
  SchemaField sf = schema.getFieldOrNull(src.getName());
  if (sf == null) { // remove this field
    return null;
  }
  FieldType type = PreAnalyzedField.createFieldType(sf);
  if (type == null) { // neither indexed nor stored - skip
    return null;
  }
  SolrInputField res = new SolrInputField(src.getName());
  res.setBoost(src.getBoost());
  for (Object o : src) {
    if (o == null) {
      continue;
    }
    Field pre = (Field)parser.createField(sf, o, 1.0f);
    if (pre != null) {
      res.addValue(pre, 1.0f);
    } else { // restore the original value
      log.warn("Could not parse field {} - using original value as is: {}", src.getName(), o);
      res.addValue(o, 1.0f);
    }
  }
  return res;
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:PreAnalyzedUpdateProcessorFactory.java

示例3: testSolrInputFieldEquality

import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
public void testSolrInputFieldEquality() {
  String randomString = TestUtil.randomSimpleString(random(), 10, 20);

  int val = random().nextInt();
  SolrInputField sif1 = new SolrInputField(randomString);
  sif1.setValue(val, 1.0f);
  SolrInputField sif2 = new SolrInputField(randomString);
  sif2.setValue(val, 1.0f);

  assertTrue(assertSolrInputFieldEquals(sif1, sif2));

  sif1.setBoost(2.1f);
  sif2.setBoost(2.1f);
  assertTrue(assertSolrInputFieldEquals(sif1, sif2));

  sif2.setBoost(2.0f);
  assertFalse(assertSolrInputFieldEquals(sif1, sif2));

  sif2.setName("foo");
  assertFalse(assertSolrInputFieldEquals(sif1, sif2));


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

示例4: mutate

import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
protected final SolrInputField mutate(final SolrInputField srcField) {
  List<String> messages = null;
  SolrInputField result = new SolrInputField(srcField.getName());
  for (final Object srcVal : srcField.getValues()) {
    final Object destVal = mutateValue(srcVal);
    if (SKIP_FIELD_VALUE_LIST_SINGLETON == destVal) {
      log.debug("field '{}' {} value '{}' is not mutatable, so no values will be mutated",
                new Object[] { srcField.getName(), srcVal.getClass().getSimpleName(), srcVal });
      return srcField;
    }
    if (DELETE_VALUE_SINGLETON == destVal) {
      if (log.isDebugEnabled()) {
        if (null == messages) {
          messages = new ArrayList<>();
        }
        messages.add(String.format(Locale.ROOT, "removing value from field '%s': %s '%s'", 
                                   srcField.getName(), srcVal.getClass().getSimpleName(), srcVal));
      }
    } else {
      if (log.isDebugEnabled()) {
        if (null == messages) {
          messages = new ArrayList<>();
        }
        messages.add(String.format(Locale.ROOT, "replace value from field '%s': %s '%s' with %s '%s'", 
                                   srcField.getName(), srcVal.getClass().getSimpleName(), srcVal, 
                                   destVal.getClass().getSimpleName(), destVal));
      }
      result.addValue(destVal, 1.0F);
    }
  }
  result.setBoost(srcField.getBoost());
  
  if (null != messages && log.isDebugEnabled()) {
    for (String message : messages) {
      log.debug(message);
    }
  }
  return 0 == result.getValueCount() ? null : result;
}
 
开发者ID:europeana,项目名称:search,代码行数:40,代码来源:AllValuesOrNoneFieldMutatingUpdateProcessor.java

示例5: field

import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
/**
 * Convenience method for building up SolrInputFields
 */
final SolrInputField field(String name, float boost, Object... values) {
  SolrInputField f = new SolrInputField(name);
  for (Object v : values) {
    f.addValue(v, 1.0F);
  }
  f.setBoost(boost);
  return f;
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:UpdateProcessorTestBase.java

示例6: field

import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
/** 
 * Convenience method for building up SolrInputFields
 */
SolrInputField field(String name, float boost, Object... values) {
  SolrInputField f = new SolrInputField(name);
  for (Object v : values) {
    f.addValue(v, 1.0F);
  }
  f.setBoost(boost);
  return f;
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:UUIDUpdateProcessorFallbackTest.java

示例7: mutate

import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
protected final SolrInputField mutate(final SolrInputField srcField) {
  List<String> messages = null;
  SolrInputField result = new SolrInputField(srcField.getName());
  for (final Object srcVal : srcField.getValues()) {
    final Object destVal = mutateValue(srcVal);
    if (SKIP_FIELD_VALUE_LIST_SINGLETON == destVal) {
      log.debug("field '{}' {} value '{}' is not mutatable, so no values will be mutated",
                new Object[] { srcField.getName(), srcVal.getClass().getSimpleName(), srcVal });
      return srcField;
    }
    if (DELETE_VALUE_SINGLETON == destVal) {
      if (log.isDebugEnabled()) {
        if (null == messages) {
          messages = new ArrayList<String>();
        }
        messages.add(String.format(Locale.ROOT, "removing value from field '%s': %s '%s'", 
                                   srcField.getName(), srcVal.getClass().getSimpleName(), srcVal));
      }
    } else {
      if (log.isDebugEnabled()) {
        if (null == messages) {
          messages = new ArrayList<String>();
        }
        messages.add(String.format(Locale.ROOT, "replace value from field '%s': %s '%s' with %s '%s'", 
                                   srcField.getName(), srcVal.getClass().getSimpleName(), srcVal, 
                                   destVal.getClass().getSimpleName(), destVal));
      }
      result.addValue(destVal, 1.0F);
    }
  }
  result.setBoost(srcField.getBoost());
  
  if (null != messages && log.isDebugEnabled()) {
    for (String message : messages) {
      log.debug(message);
    }
  }
  return 0 == result.getValueCount() ? null : result;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:40,代码来源:AllValuesOrNoneFieldMutatingUpdateProcessor.java

示例8: predefineLangToMultiLangField

import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
private void predefineLangToMultiLangField(SolrInputDocument doc, String fieldParam) throws IOException {
    SolrInputField inputField = doc.getField(fieldParam);
    SolrInputField newInputField = new SolrInputField(fieldParam);

    MultiLangField multiLangField = (MultiLangField) this.schema.getFieldType(fieldParam);
    MultiLangFieldSetting multiLangFieldSetting = ((MultiLangAnalyzer) multiLangField.getAnalyzer()).getSetting();
    if (null != inputField && null != inputField.getValues()) {
        for (Object value : inputField.getValues()) {
            if (value instanceof String) {
                String source = HTMLScriptCharFilterHelper.filterHTML((String) value);
                List<DetectedLanguage> detectedLanguages = detectLanguage(source);
                Set<String> langSet = resolveLanguage(detectedLanguages, this.setting.getFallback());

                StringBuffer predefinedLangs = new StringBuffer();
                for (String lang : langSet) {
                    if (multiLangFieldSetting.isIgnoreMissingMappings()
                            || multiLangFieldSetting.getFieldTypeMappings().containsKey(lang)) {
                        if (predefinedLangs.length() > 0) {
                            predefinedLangs.append(multiLangFieldSetting.getMultiKeyDelimiter());
                        }
                        predefinedLangs.append(lang);
                    }
                }
                if (predefinedLangs.length() > 0) {
                    predefinedLangs.append(multiLangFieldSetting.getKeyFromTextDelimiter());
                }

                if (this.setting.isHidePreLangs()) {
                    predefinedLangs.insert(0, MultiLangFieldSetting.LEFT_DELIMITER_OF_HIDDEN_FLAG);
                    predefinedLangs.append(MultiLangFieldSetting.RIGHT_DELIMITER_OF_HIDDEN_FLAG);
                }

                String newValue = predefinedLangs + source;
                newInputField.addValue(newValue, DEFAULT_BOOST_OF_SOLR_INPUT_DOCUMENT);
                newInputField.setBoost(inputField.getBoost());

                doc.remove(inputField);
                doc.put(fieldParam, newInputField);
            }
        }
    }
}
 
开发者ID:smalldirector,项目名称:solr-multilingual-analyzer,代码行数:43,代码来源:MultiLangIdentifierUpdateProcessor.java


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