To get the last version of Elastica go to the following site and in the "Download" part take the zip format. Then unzip the whole archive and copy the lib/Elastica folder into plugins/index.elasticsearch of your Pydio folder.
Why ElasticSearch?
Based on Apache Lucène and more powerful and efficient.
Why Elastica?
This is the PHP implementation that has the most features available currently.
Install ElasticSearch on Ubuntu:
To be able to install ElasticSearch you have to get and install the openjdk 7. In order to install the openjdk 7 you just have to run the following command lines:
$ sudo apt-get update
$ sudo apt-get install openjdk-7-jre-headless -y
$ wget https://downloads.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.2.deb
$ sudo dpkg -i elasticsearch-0.90.2.deb
$ sudo service elasticsearch start
$ rm elasticsearch-0.90.2.deb
$ curl -XPUT 'localhost:9200/test_index'
$ curl -XPUT 'localhost:9200/test_index/test_type/1' -d '{"user":"test", "message":"this is a test"}'This will add a document with id equals to 1 containing two fields "user" and "message" that respective values are "test" and "this is a test".
$ curl -XGET 'localhost:9200/test_index/test_type/1'If you followed the previous steps the result should be something like this:
{ "_index":"test_index", "_type":"test_type", "_id":"1", "_version":1, "exists":true, "_source" : { "user":"test", "message":"this is a test" } }
$ curl -XGET 'localhost:9200/test_index/test_type/_search' -d '{ "query":{ "match":{ "message":"this is a test" } } }'The result should be something like that:
{ "took":143, "timed_out":false, "_shards":{ "total":5, "successful":5, "failed":0 }, "hits":{ "total":1, "max_score":0.30685282, "hits":[ { "_index":"test_index", "_type":"test_type", "_id":"1", "_score":0.30685282, "_source" : { "user":"test", "message":"this is a test" } } ] } }
$client = new Elastica\Client(array("host" => "localhost", "port" => "9200")); $index = $client->getIndex("test_index"); if(!$index->exists()){ $index->create(); } $index->open(); $type = $index->getType("test_type"); $data = array(); $data["user"] = "test"; $data["message"] = "this is a test"; $id = 1; $doc = new Elastica\Document($id, $data); $type->addDocument($doc); $index->close()- Here is the code snippet that allows you to get docs by id and by query (this is the equivalent as the examples for the test):
$client = new Elastica\Client(array("host" => "localhost", "port" => "9200")); $index = $client->getIndex("test_index"); if(!$index->exists()){ $index->create(); } $index->open(); $type = $index->getType("test_type"); /* document fetched by id*/ $doc = $type->getDocument(1) /* documents fetched by query */ $query = "this is a test"; $matchQuery = new Elastica\Query\Match(); $matchQuery->setField("message"); $matchQuery->setQueryString($query); $resultSet = $type->search($matchQuery); $results = resultSet->getResults(); /* now you can go all over the results */ foreach($results as $hit){ /* print the data from the hit */ print_r($hit->getSource()); }