0. preparation
- add jars to lib folder (/tz.search/lib)
elasticsearch-1.0.0.jar
lucene-analyzers-common-4.6.1.jar
lucene-codecs-4.6.1.jar
lucene-core-4.6.1.jar
lucene-grouping-4.6.1.jar
lucene-highlighter-4.6.1.jar
lucene-join-4.6.1.jar
lucene-memory-4.6.1.jar
lucene-misc-4.6.1.jar
lucene-queries-4.6.1.jar
lucene-queryparser-4.6.1.jar
lucene-sandbox-4.6.1.jar
lucene-spatial-4.6.1.jar
lucene-suggest-4.6.1.jar
- add jars to classpath
<classpathentry kind="lib" path="lib/elasticsearch-1.0.0.jar"/>
<classpathentry kind="lib" path="lib/lucene-core-4.6.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-analyzers-common-4.6.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-codecs-4.6.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-queries-4.6.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-memory-4.6.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-highlighter-4.6.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-queryparser-4.6.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-sandbox-4.6.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-suggest-4.6.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-misc-4.6.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-join-4.6.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-grouping-4.6.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-spatial-4.6.1.jar"/>
- install elasticsearch managing console
./elasticsearch/bin/plugin -install lmenezes/elasticsearch-kopf
1. modify configuration file and sources
- modify elasticsearch nodes' configuration (elasticsearch.yml)
cluster.name: "locketCast"
- modify tz.search configuration (/tz.search/conf/application.conf)
# elasticsearch
elasticsearch.clusterName = locketCast
elasticsearch.nodes = "localhost:9300,localhost:9301,localhost:9302"
- add a service (/tz.search/app/services/ElasticsearchService.java)
- add the lines under updateLogs method in a controller (/tz.search/app/controllers/UserApi.java)
public static Result updateLogs(Long user_id, String androidId,
~~~~
// put the log into elasticsearch
ElasticsearchService.addIndexing("updatelogs", new SimpleDateFormat("yyyyMMdd").format(createdAt), logEvent.id, propertiesString);
} catch (JSONException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return ok();
}
2. run servers
/data1/elasticsearch/node1> ./start.sh
/data1/elasticsearch/node2> ./start.sh
/data1/elasticsearch/node3> ./start.sh
/Users/mac/git/tz.search> play start
3. test source
http://localhost:9000/api/user/logupdate?user_id=1&androidId=1&email=doohee323@gmail.com&eventName=1&propertiesString={"property":"Action", "value":"unlock"}
4. check the result
http://localhost:9200/_plugin/kopf/#/cluster
http://localhost:9200/_plugin/kopf/#/rest
-> http://localhost:9200/_search?q=property:Action
-> http://localhost:9200/updatelogs/20140423/_search
-> http://localhost:9200/updatelogs/20140423/_count?q=property:Action
Comments
Post a Comment