本文整理汇总了Java中org.elasticsearch.index.mapper.MappedFieldType.termQuery方法的典型用法代码示例。如果您正苦于以下问题:Java MappedFieldType.termQuery方法的具体用法?Java MappedFieldType.termQuery怎么用?Java MappedFieldType.termQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.index.mapper.MappedFieldType
的用法示例。
在下文中一共展示了MappedFieldType.termQuery方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newTermQuery
import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
@Override
protected Query newTermQuery(Term term) {
MappedFieldType currentFieldType = context.fieldMapper(term.field());
if (currentFieldType == null || currentFieldType.tokenized()) {
return super.newTermQuery(term);
}
return currentFieldType.termQuery(term.bytes(), context);
}
示例2: termQuery
import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
protected final Query termQuery(MappedFieldType fieldType, Object value, boolean lenient) {
try {
return fieldType.termQuery(value, context);
} catch (RuntimeException e) {
if (lenient) {
return null;
}
throw e;
}
}
示例3: prepareDeleteOnPrimary
import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
public Engine.Delete prepareDeleteOnPrimary(String type, String id, long version, VersionType versionType) {
verifyPrimary();
final DocumentMapper documentMapper = docMapper(type).getDocumentMapper();
final MappedFieldType uidFieldType = documentMapper.uidMapper().fieldType();
final Query uidQuery = uidFieldType.termQuery(Uid.createUid(type, id), null);
final Term uid = MappedFieldType.extractTerm(uidQuery);
return prepareDelete(type, id, uid, SequenceNumbersService.UNASSIGNED_SEQ_NO, primaryTerm, version,
versionType, Engine.Operation.Origin.PRIMARY);
}
示例4: prepareDeleteOnReplica
import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
public Engine.Delete prepareDeleteOnReplica(String type, String id, long seqNo, long primaryTerm,
long version, VersionType versionType) {
verifyReplicationTarget();
final DocumentMapper documentMapper = docMapper(type).getDocumentMapper();
final MappedFieldType uidFieldType = documentMapper.uidMapper().fieldType();
final Query uidQuery = uidFieldType.termQuery(Uid.createUid(type, id), null);
final Term uid = MappedFieldType.extractTerm(uidQuery);
return prepareDelete(type, id, uid, seqNo, primaryTerm, version, versionType, Engine.Operation.Origin.REPLICA);
}
示例5: create
import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
/**
* Create a new geohash filter for a given set of geohashes. In general this method
* returns a boolean filter combining the geohashes OR-wise.
*
* @param context Context of the filter
* @param fieldType field mapper for geopoints
* @param geohash mandatory geohash
* @param geohashes optional array of additional geohashes
* @return a new GeoBoundinboxfilter
*/
public static Query create(QueryParseContext context, BaseGeoPointFieldMapper.GeoPointFieldType fieldType, String geohash,
@Nullable List<CharSequence> geohashes) {
MappedFieldType geoHashMapper = fieldType.geoHashFieldType();
if (geoHashMapper == null) {
throw new IllegalArgumentException("geohash filter needs geohash_prefix to be enabled");
}
if (geohashes == null || geohashes.size() == 0) {
return geoHashMapper.termQuery(geohash, context);
} else {
geohashes.add(geohash);
return geoHashMapper.termsQuery(geohashes, context);
}
}
示例6: termQuery
import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
protected final Query termQuery(MappedFieldType fieldType, Object value, boolean lenient) {
try {
return fieldType.termQuery(value, parseContext);
} catch (RuntimeException e) {
if (lenient) {
return null;
}
throw e;
}
}
示例7: singleQuery
import org.elasticsearch.index.mapper.MappedFieldType; //导入方法依赖的package包/类
protected Query singleQuery(MatchQuery.Type type, String fieldName, BytesRef queryString) {
String field;
MappedFieldType fieldType = mapperService.smartNameFieldType(fieldName);
if (fieldType == null) {
field = fieldName;
} else {
field = fieldType.names().indexName();
}
if (fieldType != null && fieldType.useTermQueryWithQueryString() && !forceAnalyzeQueryString()) {
try {
return fieldType.termQuery(queryString, null);
} catch (RuntimeException e) {
return null;
}
}
Analyzer analyzer = getAnalyzer(fieldType);
InnerQueryBuilder builder = new InnerQueryBuilder(analyzer, fieldType);
Query query;
switch (type) {
case BOOLEAN:
if (options.commonTermsCutoff() == null) {
query = builder.createBooleanQuery(field, BytesRefs.toString(queryString), options.operator());
} else {
query = builder.createCommonTermsQuery(
field,
BytesRefs.toString(queryString),
options.operator(),
options.operator(),
options.commonTermsCutoff(),
fieldType
);
}
break;
case PHRASE:
query = builder.createPhraseQuery(field, BytesRefs.toString(queryString), options.phraseSlop());
break;
case PHRASE_PREFIX:
query = builder.createPhrasePrefixQuery(
field,
BytesRefs.toString(queryString),
options.phraseSlop(),
options.maxExpansions()
);
break;
default:
throw new IllegalArgumentException("invalid type: " + type.toString());
}
if (query == null) {
return zeroTermsQuery();
} else {
return query;
}
}