Elastic Search Sorting, All Documents and Pagination

If you have viewed the php docs for elastic search https://github.com/elasticsearch/elasticsearch-php/tree/v1.3.2

You note they don’t talk about a lot of really basic operations. After some trial and error I have come across some of those mentioned above.

Pagination

$searchParams['body']['from'] = $request->current_page*$request->per_page;
$searchParams['body']['size'] = $request->per_page;

All Documents Queury

$searchParams['body']['from'] = $request->current_page*$request->per_page;
$searchParams['body']['size'] = $request->per_page;
$searchParams['body']['query']['match_all']=[];

Sorting Results

$searchParams['body']['sort']['id']='desc';
$searchParams['body']['from'] = $request->current_page*$request->per_page;
$searchParams['body']['size'] = $request->per_page;
$searchParams['body']['query']['match_all']=[];

 

Happy searching.

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Elastic Search homestead and Forge

If you have tried installing elastic search http://www.elasticsearch.org/ on forge or homestead you probably have run into this error.

Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME

At this point you may want to try installng open jdk. Well don’t. The errors don’t go away.

Instead install oracle java.

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get install oracle-java7-installer

 

I am not sure why open jdk doesn’t work.  If you do know or have made it work please post a comment.

 

Facebooktwittergoogle_plusredditpinterestlinkedinmail