Watch 45 Star 167 Fork 51

bboss / bboss-elasticsearchJavaApache-2.0

Join us
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
the best elasticsearch highlevel java rest api-----bboss spread retract

Clone or download

Elasticsearch Bboss

Bboss is a good elasticsearch Java rest client. It operates and accesses elasticsearch in a way similar to mybatis.

Environmental requirements

JDK requirement: JDK 1.7+

Elasticsearch version requirements: 1.X,2.X,5.X,6.X,7.x,+

Spring booter 1.x,2.x,+

Build from source code

First Get source code from

Then change to cmd window under directory bboss-elasticsearch and run gradle build command:

gradle install

Gradle environmenet install and config document:

How to use Elasticsearch BBoss.

First add the maven dependency of BBoss to your pom.xml:


If it's a spring boot project, you can replace the Maven coordinate above with the following Maven coordinate:


Next, add the Elasticsearch addresses to the file under the project resource directory, and create a new one if the file does not exist:

#Cluster addresses are separated by commas,,

And last create a jsp file named testElasticsearch.jsp :

<%@ page import="org.frameworkset.elasticsearch.ElasticSearchHelper" %>
<%@ page import="org.frameworkset.elasticsearch.client.ClientInterface" %>
<%@ page import="org.frameworkset.elasticsearch.entity.ESDatas" %>
<%@ page import="org.frameworkset.elasticsearch.scroll.ScrollHandler" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="com.frameworkset.common.poolman.SQLExecutor" %>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="org.frameworkset.elasticsearch.scroll.HandlerInfo" %>
	ClientInterface clientUtil = ElasticSearchHelper.getRestClientUtil();
	//get elasticsearch cluster state
	String result = clientUtil.executeHttp("_cluster/state?pretty",ClientInterface.HTTP_GET);

	//check indice twitter and index type tweet exist or not.
	boolean exist1 = clientUtil.existIndiceType("twitter","tweet");
	out.println("twitter  tweet type exist:"+exist1);
	//check indice twitter exist or not
	exist1 = clientUtil.existIndice("twitter");
	out.println("twitter exist:"+exist1);
	//count documents in indice twitter
	long count = clientUtil.countAll("twitter");

	//Get All documents of indice twitter,DEFAULT_FETCHSIZE is 5000
	ESDatas<Map> esDatas = clientUtil.searchAll("twitter", Map.class);

	//Get All documents of indice twitter,Set fetchsize to 10000, Using ScrollHandler to process each batch of datas.
	clientUtil.searchAll("twitter",10000,new ScrollHandler<Map>() {
		public void handle(ESDatas<Map> esDatas, HandlerInfo handlerInfo) throws Exception {
			List<Map> dataList = esDatas.getDatas();
			if(dataList != null) {
				System.out.println("dataList.size:" + dataList.size());
			//do something other such as do a db query.
			//SQLExecutor.queryList(Map.class,"select * from td_sm_user");
    //Use slice parallel scoll query all documents of indice  twitter by 2 thread tasks. DEFAULT_FETCHSIZE is 5000
	//You can also use ScrollHandler to process each batch of datas on your own.
	esDatas = clientUtil.searchAllParallel("twitter", Map.class,2);

Put the file into the web project that has been connected to pinpoint, run the program, log on pinpoint to see the execution effect of bboss plugin.

Elasticsearch Java Demos

The following Demo and related documentation is compatible with Elasticsearch 1.x,2.X,5.X,6.X,+ versions

Elasticsearch demo for Java project:

Elasticsearch demo for spring booter 1.x,2.x

Fast integration bboss documentation

Spring boot integration ElasticSearch case sharing

Quickly integrate Elasticsearch Restful API case sharing

Quick Start

Elasticsearch BBoss Developer Tutorial

High-performance elasticsearch ORM library bboss use introduction



GitHub Logo


The BBoss Framework is released under version 2.0 of the Apache License.

Comments ( 10 )

Sign in for post a comment


Help Search