本文整理匯總了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;
}
示例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())));
}
}
示例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;
}
示例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;
}
示例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;
}