Clean Architecture Masterclass

Clean Architecture MasterclassMay 28-29

Join

East-Es-Logo

Born To Simplify Development

maven code style

What is Easy-Es?

Easy-Es is a powerfully enhanced toolkit of RestHighLevelClient for simplify development. This toolkit provides some efficient, useful, out-of-the-box features for ElasticSearch. By using Easy-Es, you can use MySQL syntax to complete Es queries. Use it can effectively save your development time.

Official website

easy-es website https://en.easy-es.cn/

easy-es gitee https://gitee.com/dromara/easy-es

easy-es github https://github.com/dromara/easy-es

dromara website https://dromara.org/

dromara gitee homepage https://gitee.com/dromara/

Links

Features

Compare

Demand: Query all documents with title equals "Hi" and author equals "Guy"


// Use Easy-Es to complete the query with only 1 lines of code
List<Document> documents = documentMapper.selectList(EsWrappers.lambdaQuery(Document.class).eq(Document::getTitle, "Hi").eq(Document::getCreator, "Guy"));
// Query with RestHighLevelClient requires 11 lines of code, not including parsing JSON code
String indexName = "document";
        SearchRequest searchRequest = new SearchRequest(indexName);
        BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
        TermQueryBuilder titleTerm = QueryBuilders.termQuery("title", "Hi");
        TermsQueryBuilder creatorTerm = QueryBuilders.termsQuery("creator", "Guy");
        boolQueryBuilder.must(titleTerm);
        boolQueryBuilder.must(creatorTerm);
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(boolQueryBuilder);
        searchRequest.source(searchSourceBuilder);
        try {
        SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
        // Then parse the DocumentList from searchResponse in various ways, omitting these codes...
        } catch (IOException e) {
        e.printStackTrace();
        }

The above is just a simple query demonstration. The more complex the actual query scene, the better the effect, which can save 3-5 times the amount of code on average.

Getting started

This showcase is just a small part of Easy-Es features. If you want to learn more, please refer to the documentation.

Architecture

Architecture

MySQL Easy-Es and Es syntax comparison table

MySQL Easy-Es Es-DSL/Es java api
and and must
or or should
= eq term
!= ne boolQueryBuilder.mustNot(queryBuilder)
> gt QueryBuilders.rangeQuery('es field').gt()
>= ge .rangeQuery('es field').gte()
< lt .rangeQuery('es field').lt()
<= le .rangeQuery('es field').lte()
like '%field%' like QueryBuilders.wildcardQuery(field,value)
not like '%field%' notLike must not wildcardQuery(field,value)
like '%field' likeLeft QueryBuilders.wildcardQuery(field,*value)
like 'field%' likeRight QueryBuilders.wildcardQuery(field,value*)
between between QueryBuilders.rangeQuery('es field').from(xx).to(xx)
notBetween notBetween must not QueryBuilders.rangeQuery('es field').from(xx).to(xx)
is null isNull must not QueryBuilders.existsQuery(field)
is notNull isNotNull QueryBuilders.existsQuery(field)
in in QueryBuilders.termsQuery(" xx es field", xx)
not in notIn must not QueryBuilders.termsQuery(" xx es field", xx)
group by groupBy AggregationBuilders.terms()
order by orderBy fieldSortBuilder.order(ASC/DESC)
min min AggregationBuilders.min
max max AggregationBuilders.max
avg avg AggregationBuilders.avg
sum sum AggregationBuilders.sum
order by xxx asc orderByAsc fieldSortBuilder.order(SortOrder.ASC)
order by xxx desc orderByDesc fieldSortBuilder.order(SortOrder.DESC)
- match matchQuery
- matchPhrase QueryBuilders.matchPhraseQuery
- matchPrefix QueryBuilders.matchPhrasePrefixQuery
- queryStringQuery QueryBuilders.queryStringQuery
select * matchAllQuery QueryBuilders.matchAllQuery()
- highLight HighlightBuilder.Field
... ... ...

Advertising provider

ad


ad
ad
ad

Donate Easy-Es

License

Easy-Es is under the Apache 2.0 license. See the Apache License 2.0 file for details.

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.