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


Java Field.setBoost方法代码示例

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


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

示例1: parse

import org.apache.lucene.document.Field; //导入方法依赖的package包/类
/**
 * Parse using the provided {@link ParseContext} and return a mapping
 * update if dynamic mappings modified the mappings, or {@code null} if
 * mappings were not modified.
 */
public Mapper parse(ParseContext context) throws IOException {
    final List<Field> fields = new ArrayList<>(2);
    try {
        parseCreateField(context, fields);
        for (Field field : fields) {
            if (!customBoost()) {
                field.setBoost(fieldType().boost());
            }
            context.doc().add(field);
        }
    } catch (Exception e) {
        throw new MapperParsingException("failed to parse [" + fieldType().names().fullName() + "]", e);
    }
    multiFields.parse(this, context);
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:FieldMapper.java

示例2: parseCreateField

import org.apache.lucene.document.Field; //导入方法依赖的package包/类
@Override
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
    ValueAndBoost valueAndBoost = parseCreateFieldForString(context, fieldType().nullValueAsString(), fieldType().boost());
    if (valueAndBoost.value() == null) {
        return;
    }
    if (ignoreAbove > 0 && valueAndBoost.value().length() > ignoreAbove) {
        return;
    }
    if (context.includeInAll(includeInAll, this)) {
        context.allEntries().addText(fieldType().names().fullName(), valueAndBoost.value(), valueAndBoost.boost());
    }

    if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) {
        Field field = new Field(fieldType().names().indexName(), valueAndBoost.value(), fieldType());
        field.setBoost(valueAndBoost.boost());
        fields.add(field);
    }
    if (fieldType().hasDocValues()) {
        fields.add(new SortedSetDocValuesField(fieldType().names().indexName(), new BytesRef(valueAndBoost.value())));
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:StringFieldMapper.java

示例3: parse

import org.apache.lucene.document.Field; //导入方法依赖的package包/类
@Override
public Mapper parse(ParseContext context) throws IOException {
    try {
        Shape shape = context.parseExternalValue(Shape.class);
        if (shape == null) {
            ShapeBuilder shapeBuilder = ShapeBuilder.parse(context.parser(), this);
            if (shapeBuilder == null) {
                return null;
            }
            shape = shapeBuilder.build();
        }
        if (fieldType().pointsOnly() && !(shape instanceof Point)) {
            throw new MapperParsingException("[{" + fieldType().name() + "}] is configured for points only but a " +
                    ((shape instanceof JtsGeometry) ? ((JtsGeometry)shape).getGeom().getGeometryType() : shape.getClass()) + " was found");
        }
        Field[] fields = fieldType().defaultStrategy().createIndexableFields(shape);
        if (fields == null || fields.length == 0) {
            return null;
        }
        for (Field field : fields) {
            if (!customBoost() &&
                fieldType.boost() != 1f && Version.indexCreated(context.indexSettings()).before(Version.V_5_0_0_alpha1)) {
                field.setBoost(fieldType().boost());
            }
            context.doc().add(field);
        }
    } catch (Exception e) {
        throw new MapperParsingException("failed to parse [" + fieldType().name() + "]", e);
    }
    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:GeoShapeFieldMapper.java

示例4: extractSubnodeDocuments

import org.apache.lucene.document.Field; //导入方法依赖的package包/类
/**
    * Adds documents made of subnodes' title, descriptions and uid, then descents deeper into descendants.
    *
    * @param node
    *            its subnodes will be parsed
    * @return documents made of all of node's descendants
    */
   private Set<Document> extractSubnodeDocuments(PedagogicalPlannerSequenceNode node) {
Set<Document> docs = new HashSet<Document>();
if ((node != null) && (node.getSubnodes() != null)) {
    for (PedagogicalPlannerSequenceNode subnode : node.getSubnodes()) {
	Document doc = new Document();
	Field titleField = new TextField(PedagogicalPlannerAction.FIELD_NAME_TITLE, subnode.getTitle(),
		Field.Store.NO);
	titleField.setBoost(10);
	doc.add(titleField);

	String briefDesc = WebUtil.removeHTMLtags(subnode.getBriefDescription());
	if (briefDesc != null) {
	    Field briefDescField = new TextField(PedagogicalPlannerAction.FIELD_NAME_BRIEF_DESCRIPTION,
		    briefDesc, Field.Store.NO);
	    doc.add(briefDescField);
	}
	String fullDesc = WebUtil.removeHTMLtags(subnode.getFullDescription());
	if (fullDesc != null) {
	    Field fullDescField = new TextField(PedagogicalPlannerAction.FIELD_NAME_FULL_DESCRIPTION, fullDesc,
		    Field.Store.NO);
	    doc.add(fullDescField);
	}

	Field uidField = new StringField(PedagogicalPlannerAction.FIELD_NAME_ANCESTOR_UID,
		subnode.getUid().toString(), Field.Store.YES);
	doc.add(uidField);
	docs.add(doc);

	Set<Document> subnodeDocs = extractSubnodeDocuments(subnode);
	docs.addAll(subnodeDocs);
    }
}
return docs;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:PedagogicalPlannerAction.java

示例5: parse

import org.apache.lucene.document.Field; //导入方法依赖的package包/类
@Override
public Mapper parse(ParseContext context) throws IOException {
    try {
        Shape shape = context.parseExternalValue(Shape.class);
        if (shape == null) {
            ShapeBuilder shapeBuilder = ShapeBuilder.parse(context.parser(), this);
            if (shapeBuilder == null) {
                return null;
            }
            shape = shapeBuilder.build();
        }
        if (fieldType().pointsOnly() && !(shape instanceof Point)) {
            throw new MapperParsingException("[{" + fieldType().names().fullName() + "}] is configured for points only but a " +
                    ((shape instanceof JtsGeometry) ? ((JtsGeometry)shape).getGeom().getGeometryType() : shape.getClass()) + " was found");
        }
        Field[] fields = fieldType().defaultStrategy().createIndexableFields(shape);
        if (fields == null || fields.length == 0) {
            return null;
        }
        for (Field field : fields) {
            if (!customBoost()) {
                field.setBoost(fieldType().boost());
            }
            context.doc().add(field);
        }
    } catch (Exception e) {
        throw new MapperParsingException("failed to parse [" + fieldType().names().fullName() + "]", e);
    }
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:31,代码来源:GeoShapeFieldMapper.java


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