本文整理匯總了Java中org.elasticsearch.index.query.QueryBuilders.prefixQuery方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryBuilders.prefixQuery方法的具體用法?Java QueryBuilders.prefixQuery怎麽用?Java QueryBuilders.prefixQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.index.query.QueryBuilders
的用法示例。
在下文中一共展示了QueryBuilders.prefixQuery方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createLexicalQuery
import org.elasticsearch.index.query.QueryBuilders; //導入方法依賴的package包/類
private static QueryBuilder createLexicalQuery(String key, Map<String, Object> rangeOperation,
Float boost) {
QueryBuilder queryBuilder = null;
for (Map.Entry<String, Object> it : rangeOperation.entrySet()) {
if (it.getKey().equalsIgnoreCase(STARTS_WITH)) {
if (isNotNull(boost)) {
queryBuilder = QueryBuilders.prefixQuery(key + RAW_APPEND, (String) it.getValue())
.boost(boost);
}
queryBuilder = QueryBuilders.prefixQuery(key + RAW_APPEND, (String) it.getValue());
} else if (it.getKey().equalsIgnoreCase(ENDS_WITH)) {
String endsWithRegex = "~" + it.getValue();
if (isNotNull(boost)) {
queryBuilder = QueryBuilders.regexpQuery(key + RAW_APPEND, endsWithRegex).boost(boost);
}
queryBuilder = QueryBuilders.regexpQuery(key + RAW_APPEND, endsWithRegex);
}
}
return queryBuilder;
}
示例2: prefixTextQuerySingleField
import org.elasticsearch.index.query.QueryBuilders; //導入方法依賴的package包/類
/**
* Return all hits which begin with <code>prefix</code>, e.g. "Wh"
* @param prefix
* @param fieldName
* @param start
* @param count
* @return
*/
public String prefixTextQuerySingleField(String prefix, String fieldName, int start, int count) {
QueryBuilder qb = QueryBuilders.prefixQuery(fieldName, prefix);
SearchSourceBuilder ssb = new SearchSourceBuilder();
ssb.query(qb);
ssb.from(start);
if (count > -1)
ssb.size(count);
return ssb.toString();
}
示例3: testForClient
import org.elasticsearch.index.query.QueryBuilders; //導入方法依賴的package包/類
@Test
public void testForClient() throws Exception {
QueryBuilder qb = QueryBuilders.prefixQuery(
"brand",
"heine"
);
client.prepareSearch().setQuery(qb).execute().actionGet();
}
示例4: startsWith
import org.elasticsearch.index.query.QueryBuilders; //導入方法依賴的package包/類
private static QueryBuilder startsWith(String fieldName, String value) {
return QueryBuilders.prefixQuery(fieldName, value);
}
示例5: prefixQuery
import org.elasticsearch.index.query.QueryBuilders; //導入方法依賴的package包/類
/**
* Builds a string prefix query.
*
* <p>
* Tests if the attribute of an instance starts with the specified value.
* </p>
* <p>
* Used internally in {@link IndexedStore#findAll(Params)} or in custom search methods in inheriting classes.
* </p>
*
* @param name Name of the attribute to check
* @param value Value to test against
* @return Elasticsearch query builder
*/
default QueryBuilder prefixQuery(String name, String value) {
return QueryBuilders.prefixQuery(name, value);
}