當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。