org.elasticsearch.index.query.TermQueryBuilder Java Examples

The following examples show how to use org.elasticsearch.index.query.TermQueryBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Select.java    From code with Apache License 2.0 7 votes vote down vote up
/**
 * 布尔与词条查询
 * 语法:
 *  QueryBuilders:查询构建器工厂
 *      BoolQueryBuilder:布尔查询构建器
 *      TermQueryBuilder:词条查询构建器
 * 示例:
 *  查询名称包含手机的,并且品牌为小米的记录
 */
@Test
public void test2() throws IOException {
    //2.封装查询请求
    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
    // 布尔查询构建器
    BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
    MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery("name", "手机");
    // 词条查询构建器
    TermQueryBuilder termQueryBuilder = QueryBuilders.termQuery("brandName", "小米");

    boolQueryBuilder.must(matchQueryBuilder);
    boolQueryBuilder.must(termQueryBuilder);

    searchSourceBuilder.query(boolQueryBuilder);
    searchRequest.source(searchSourceBuilder);

}
 
Example #2
Source File: ExplorerQueryBuilderTests.java    From elasticsearch-learning-to-rank with Apache License 2.0 5 votes vote down vote up
@Override
protected ExplorerQueryBuilder doCreateTestQueryBuilder() {
    ExplorerQueryBuilder builder = new ExplorerQueryBuilder();
    builder.query(new TermQueryBuilder("foo", "bar"));
    builder.statsType("sum_raw_ttf");
    return builder;
}
 
Example #3
Source File: RepositoryIntegrationTest.java    From elastic-crud with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldFindByFirstnameAndLastname() {
  final Person saved = repository.save(PERSON);
  final TermQueryBuilder byFirstname = new TermQueryBuilder("firstname", PERSON.getFirstname());
  final TermQueryBuilder byLastname = new TermQueryBuilder("lastname", PERSON.getLastname());
  final BoolQueryBuilder bool = new BoolQueryBuilder()
    .must(byFirstname)
    .must(byLastname);

  final List<Person> search = repository.search(bool);
  assertEquals(1, search.size());
  assertEquals(saved, search.get(0));
  repository.delete(saved);
}
 
Example #4
Source File: BsBoostDocumentRuleCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setBoostExpr_Equal(String boostExpr, ConditionOptionCall<TermQueryBuilder> opLambda) {
    setBoostExpr_Term(boostExpr, opLambda);
}
 
Example #5
Source File: BsFailureUrlCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setErrorCount_Term(Integer errorCount, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("errorCount", errorCount);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #6
Source File: BsWebConfigCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setVirtualHosts_Term(String virtualHosts, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("virtualHosts", virtualHosts);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #7
Source File: BsDataConfigCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setDescription_Term(String description, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("description", description);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #8
Source File: BsLabelTypeCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setCreatedTime_Term(Long createdTime, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("createdTime", createdTime);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #9
Source File: BsBoostDocumentRuleCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setCreatedBy_Term(String createdBy, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("createdBy", createdBy);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #10
Source File: BsAccessTokenCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setParameterName_Term(String parameterName, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("parameter_name", parameterName);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #11
Source File: BsFileConfigCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setUpdatedTime_Term(Long updatedTime, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("updatedTime", updatedTime);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #12
Source File: BsSearchLogCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setUser_Equal(String user, ConditionOptionCall<TermQueryBuilder> opLambda) {
    setUser_Term(user, opLambda);
}
 
Example #13
Source File: BsBadWordCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setTargetRole_Equal(String targetRole, ConditionOptionCall<TermQueryBuilder> opLambda) {
    setTargetRole_Term(targetRole, opLambda);
}
 
Example #14
Source File: BsWebConfigCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setBoost_Equal(Float boost, ConditionOptionCall<TermQueryBuilder> opLambda) {
    setBoost_Term(boost, opLambda);
}
 
Example #15
Source File: BsElevateWordCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setId_Equal(String id, ConditionOptionCall<TermQueryBuilder> opLambda) {
    setId_Term(id, opLambda);
}
 
Example #16
Source File: BsLabelTypeCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setId_Term(String id, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("_id", id);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #17
Source File: BsSearchLogCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setResponseTime_Term(Long responseTime, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("responseTime", responseTime);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #18
Source File: BsCrawlingInfoParamCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setCreatedTime_Term(Long createdTime, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("createdTime", createdTime);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #19
Source File: BsSearchLogCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setRequestedAt_Term(LocalDateTime requestedAt, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("requestedAt", requestedAt);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #20
Source File: BsDuplicateHostCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setUpdatedBy_Equal(String updatedBy, ConditionOptionCall<TermQueryBuilder> opLambda) {
    setUpdatedBy_Term(updatedBy, opLambda);
}
 
Example #21
Source File: BsWebAuthenticationCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setAuthRealm_Equal(String authRealm, ConditionOptionCall<TermQueryBuilder> opLambda) {
    setAuthRealm_Term(authRealm, opLambda);
}
 
Example #22
Source File: BsFileConfigCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setBoost_Equal(Float boost, ConditionOptionCall<TermQueryBuilder> opLambda) {
    setBoost_Term(boost, opLambda);
}
 
Example #23
Source File: BsPathMappingCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setRegex_Term(String regex, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("regex", regex);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #24
Source File: BsFavoriteLogCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setUserInfoId_Equal(String userInfoId, ConditionOptionCall<TermQueryBuilder> opLambda) {
    setUserInfoId_Term(userInfoId, opLambda);
}
 
Example #25
Source File: BsSearchLogCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setQueryPageSize_Term(Integer queryPageSize, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("queryPageSize", queryPageSize);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #26
Source File: BsFailureUrlCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setConfigId_Term(String configId, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("configId", configId);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #27
Source File: BsJobLogCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setJobStatus_Term(String jobStatus, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("jobStatus", jobStatus);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #28
Source File: BsRelatedQueryCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setTerm_Term(String term, ConditionOptionCall<TermQueryBuilder> opLambda) {
    TermQueryBuilder builder = regTermQ("term", term);
    if (opLambda != null) {
        opLambda.callback(builder);
    }
}
 
Example #29
Source File: BsRequestHeaderCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setWebConfigId_Equal(String webConfigId, ConditionOptionCall<TermQueryBuilder> opLambda) {
    setWebConfigId_Term(webConfigId, opLambda);
}
 
Example #30
Source File: BsWebConfigCQ.java    From fess with Apache License 2.0 4 votes vote down vote up
public void setName_Equal(String name, ConditionOptionCall<TermQueryBuilder> opLambda) {
    setName_Term(name, opLambda);
}