Giter VIP home page Giter VIP logo

play2-elasticsearch's Introduction

play2-elasticsearch

===================

This module provides Elasticsearch(v0.19.10) in a play2 application

Versions

0.1 -> init version 0.2 -> Percolators support 0.3 -> IndexResult : add pagination data 0.4 -> upgrade ES to 0.19.10

Roadmap

0.5 -> Add binding for Ebean Model via an IndexModel.class

Installing

The dependency declaration is

"com.github.cleverage" % "elasticsearch_2.9.1" % "0.4"

The resolver repository is

 resolvers += Resolver.url("GitHub Play2-elasticsearch Repository", url("http://cleverage.github.com/play2-elasticsearch/releases/"))(Resolver.ivyStylePatterns)

So the Build.scala looks like

import sbt._
import Keys._
import PlayProject._

object ApplicationBuild extends Build {

    val appName         = "elasticsearch-sample"
    val appVersion      = "1.0-SNAPSHOT"

    val appDependencies = Seq(
      // Add your project dependencies here,
      "com.github.cleverage" % "elasticsearch_2.9.1" % "0.4"
    )

    val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
      // Add your own project settings here      
      resolvers += Resolver.url("GitHub Play2-elasticsearch Repository", url("http://cleverage.github.com/play2-elasticsearch/releases/"))(Resolver.ivyStylePatterns)
    )

}

Activate the plugin

Play2-elasticsearch requires its plugin to be declared in the conf/play.plugins file. If this file doesn't exist (it's not created by default when you create a new project), just create it in the conf directory first, and then add

9000:com.github.cleverage.elasticsearch.plugin.IndexPlugin

Configuration

Add settings in conf/application.conf

## ElasticSearch Configuration
##############################
## define local mode or not
elasticsearch.local=false

## list clients
elasticsearch.client="192.168.0.46:9300"
# ex : elasticsearch.client="192.168.0.46:9300,192.168.0.47:9300"

## Name of the index
elasticsearch.index.name="play2-elasticsearch"

## define package or class separate by commas for loading @IndexType and @IndexMapping information
elasticsearch.index.clazzs="indexing.*"

## show request & result json of search request in log
elasticsearch.index.show_request=true

Usage

HelloWorld

Create an Class extends "com.github.cleverage.elasticsearch.Index"

Example : IndexTest.java

IndexTest indexTest = new IndexTest();
indexTest.name = "hello World";
indexTest.index();

IndexTest byId = IndexTest.find.byId("1");

IndexResults<IndexTest> all = IndexTest.find.all();

IndexQuery<IndexTest> indexQuery = IndexTest.find.query();
indexQuery.setBuilder(QueryBuilders.queryString("hello"));
IndexResults<IndexTest> results = IndexTest.find.search(indexQuery);

More Complex

Example : https://github.com/cleverage/play2-elasticsearch/blob/master/samples/elasticsearch-java/app/indexing/Team.java

See samples/elasticsearch-java application for more sample

Javadoc

http://cleverage.github.com/play2-elasticsearch/javadoc/

Author

@nboire & @mguillermin

play2-elasticsearch's People

Contributors

nboire avatar mguillermin avatar

Stargazers

Peter Fu avatar

Watchers

James Cloos avatar Peter Fu 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.