當前位置: 首頁>>代碼示例>>Java>>正文


Java QueryBuilders.regexpQuery方法代碼示例

本文整理匯總了Java中org.elasticsearch.index.query.QueryBuilders.regexpQuery方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryBuilders.regexpQuery方法的具體用法?Java QueryBuilders.regexpQuery怎麽用?Java QueryBuilders.regexpQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.index.query.QueryBuilders的用法示例。


在下文中一共展示了QueryBuilders.regexpQuery方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test

import org.elasticsearch.index.query.QueryBuilders; //導入方法依賴的package包/類
/**
 * Here to establish QueryBuilder patterns
 */
void test() {
	SearchSourceBuilder b;
	BoolQueryBuilder qb = QueryBuilders.boolQuery();
	QueryBuilder qbmm = QueryBuilders.multiMatchQuery("name", "fieldNames");
	QueryBuilder qbm = QueryBuilders.matchQuery("name", "text");
	QueryBuilder qbmp = QueryBuilders.matchPhraseQuery("name", "text");
	QueryBuilder qb1 = QueryBuilders.termQuery(ITQCoreOntology.TUPLE_SUBJECT_PROPERTY, "");
	QueryBuilder qb2 = QueryBuilders.termQuery(ITQCoreOntology.TUPLE_OBJECT_PROPERTY, "");
	QueryBuilder qb3 = QueryBuilders.termQuery(ITQCoreOntology.INSTANCE_OF_PROPERTY_TYPE, "");
	qb.must(qb3);
	qb.should(qb1);
	qb.should(qb2);
	QueryBuilder partial = QueryBuilders.regexpQuery("name", "regexp");
	QueryBuilder wildcard = QueryBuilders.wildcardQuery("name", "query");
}
 
開發者ID:topicquests,項目名稱:backside-servlet-ks,代碼行數:19,代碼來源:ElasticQueryDSL.java

示例2: 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;
}
 
開發者ID:project-sunbird,項目名稱:sunbird-utils,代碼行數:21,代碼來源:ElasticSearchUtil.java

示例3: testForClient

import org.elasticsearch.index.query.QueryBuilders; //導入方法依賴的package包/類
@Test
public void testForClient() throws Exception {
    QueryBuilder qb = QueryBuilders.regexpQuery(
            "name.first",
            "s.*y");
    client.prepareSearch().setQuery(qb).execute().actionGet();
}
 
開發者ID:felayman,項目名稱:elasticsearch-full,代碼行數:8,代碼來源:RegexpQueryDemo.java

示例4: suffixQuery

import org.elasticsearch.index.query.QueryBuilders; //導入方法依賴的package包/類
/**
 * Builds a string suffix query.
 *
 * <p>
 *     Tests if the attribute of an instance ends with the specified value.
 * </p>
 * <p>
 *     Used internally in {@link IndexedStore#findAll(Params)} or in custom search methods in inheriting classes.
 * </p>
 * <p>
 *     This query is considerably slower than prefix query due to the nature of indexing. Should be avoided if
 *     possible.
 * </p>
 *
 * @param name Name of the attribute to check
 * @param value Value to test against
 * @return Elasticsearch query builder
 */
default QueryBuilder suffixQuery(String name, String value) {
    return QueryBuilders.regexpQuery(name, ".*" + value);
}
 
開發者ID:LIBCAS,項目名稱:ARCLib,代碼行數:22,代碼來源:IndexedStore.java

示例5: containsQuery

import org.elasticsearch.index.query.QueryBuilders; //導入方法依賴的package包/類
/**
 * Builds a string contains query.
 *
 * <p>
 *     Tests if the attribute of an instance contains the specified value.
 * </p>
 * <p>
 *     Used internally in {@link IndexedStore#findAll(Params)} or in custom search methods in inheriting classes.
 * </p>
 * <p>
 *     This query is considerably slower than prefix query due to the nature of indexing. Should be avoided if
 *     possible.
 * </p>
 *
 * @param name Name of the attribute to check
 * @param value Value to test against
 * @return Elasticsearch query builder
 */
default QueryBuilder containsQuery(String name, String value) {
    return QueryBuilders.regexpQuery(name, ".*" + value + ".*");
}
 
開發者ID:LIBCAS,項目名稱:ARCLib,代碼行數:22,代碼來源:IndexedStore.java


注:本文中的org.elasticsearch.index.query.QueryBuilders.regexpQuery方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。