GithubHelp home page GithubHelp logo

apple006 / bboss-elasticsearch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bbossgroups/bboss-elasticsearch

0.0 0.0 0.0 13 MB

the best elasticsearch highlevel java rest api-----bboss

License: Apache License 2.0

Java 100.00%

bboss-elasticsearch's Introduction

Elasticsearch Bboss

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

https://esdoc.bbossgroups.com/#/README

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,+

bboss兼容性

bboss Elasticsearch spring boot
all 1.x 1.x,2.x
all 2.x 1.x,2.x
all 3.x 1.x,2.x
all 5.x 1.x,2.x
all 6.x 1.x,2.x
all 7.x 1.x,2.x

快速开始bboss

https://esdoc.bbossgroups.com/#/quickstart

Build from source code

First Get source code from https://github.com/bbossgroups/bboss-elasticsearch

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

gradle install

Build from source code guide:

https://esdoc.bbossgroups.com/#/bboss-build

How to use Elasticsearch BBoss.

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

       <dependency>
            <groupId>com.bbossgroups.plugins</groupId>
            <artifactId>bboss-elasticsearch-rest-jdbc</artifactId>
            <version>6.2.5</version>
        </dependency>

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

        <dependency>
            <groupId>com.bbossgroups.plugins</groupId>
            <artifactId>bboss-elasticsearch-spring-boot-starter</artifactId>
            <version>6.2.5</version>
        </dependency>

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

elasticsearch.rest.hostNames=10.21.20.168:9200

#Cluster addresses are separated by commas

#elasticsearch.rest.hostNames=10.180.211.27:9200,10.180.211.28:9200,10.180.211.29:9200

And write java code to test bboss api:

import org.frameworkset.elasticsearch.ElasticSearchHelper;
import org.frameworkset.elasticsearch.client.ClientInterface;
import org.frameworkset.elasticsearch.entity.ESDatas;
import org.frameworkset.elasticsearch.scroll.ScrollHandler;
import java.util.List;
import java.util.Map;
import com.frameworkset.common.poolman.SQLExecutor;

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");
	out.println(count);

	//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();
			System.out.println("TotalSize:"+esDatas.getTotalSize());
			if(dataList != null) {
				System.out.println("dataList.size:" + dataList.size());
			}
			else
			{
				System.out.println("dataList.size:0");
			}
			//do something other such as do a db query.
			//SQLExecutor.queryList(Map.class,"select * from td_sm_user");
		}
	},Map.class);
    //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);
	

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:

https://github.com/bbossgroups/elasticsearch-example

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

https://github.com/bbossgroups/es_bboss_web

https://github.com/bbossgroups/elasticsearch-springboot-example

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

Elasticsearch技术交流群:166471282

Elasticsearch微信公众号:bbossgroup

GitHub Logo

License

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

bboss-elasticsearch's People

Contributors

rookieygl avatar yin-bp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.