<commit_before># play2-elasticsearch
===================

This module provides [Elasticsearch](http://www.elasticsearch.org/) in a play2 application

## Installing

The dependency declaration is

```
"com.github.nboire" % "elasticsearch_2.9.1" % "0.1"
```
The resolver repository is 

```
 resolvers += Resolver.url("GitHub Play2-elasticsearch Repository", url("http://nboire.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.nboire" % "elasticsearch_2.9.1" % "0.1"
    )

    val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
      // Add your own project settings here      
      resolvers += Resolver.url("GitHub Play2-elasticsearch Repository", url("http://nboire.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.nboire.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

%test.elasticsearch.local=true
%test.elasticsearch.index.name=play2-elasticsearchtest
```

## Usage

### HelloWorld
Create an Class extends 9000:com.github.nboire.elasticsearch.Index
Example : [IndexTest.java](https://github.com/nboire/play2-elasticsearch/blob/master/samples/elasticsearch-java/app/indexing/IndexTest.java)

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

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

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

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

```

### More Complex
Example : https://github.com/nboire/play2-elasticsearch/blob/master/samples/elasticsearch-java/app/indexing/Team.java

See samples/elasticsearch-java application for more sample

## Javadoc
http://nboire.github.com/play2-elasticsearch/javadoc/<commit_msg>Adjust readme<commit_after># play2-elasticsearch
===================

This module provides [Elasticsearch](http://www.elasticsearch.org/) in a play2 application

## Installing

The dependency declaration is

```
"com.github.nboire" % "elasticsearch_2.9.1" % "0.1"
```
The resolver repository is 

```
 resolvers += Resolver.url("GitHub Play2-elasticsearch Repository", url("http://nboire.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.nboire" % "elasticsearch_2.9.1" % "0.1"
    )

    val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
      // Add your own project settings here      
      resolvers += Resolver.url("GitHub Play2-elasticsearch Repository", url("http://nboire.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.nboire.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

%test.elasticsearch.local=true
%test.elasticsearch.index.name=play2-elasticsearchtest
```

## Usage

### HelloWorld
Create an Class extends "com.github.nboire.elasticsearch.Index"

Example : [IndexTest.java](https://github.com/nboire/play2-elasticsearch/blob/master/samples/elasticsearch-java/app/indexing/IndexTest.java)

```
IndexTest indexTest = new IndexTest();
indexTest.name = "<NAME>";
indexTest.index();

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

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

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

```

### More Complex
Example : https://github.com/nboire/play2-elasticsearch/blob/master/samples/elasticsearch-java/app/indexing/Team.java

See samples/elasticsearch-java application for more sample

## Javadoc
http://nboire.github.com/play2-elasticsearch/javadoc/
{'fraction_non_alphanumeric': 0.1374485596707819, 'fraction_numerical': 0.023045267489711935, 'mean_word_length': 4.93359375, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6729632', 'n_tokens_mistral': 1899, 'n_tokens_neox': 1835, 'n_words': 419}