This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Forums » Extensions » eZ Find » Solr JSon query from ez module view

Solr JSon query from ez module view

Solr JSon query from ez module view

Wednesday 09 June 2010 11:30:45 am - 2 replies

Hi guys,

What is the cleanest way to fetch solr data, in built-in json format, from php code inside an ezpublish module view ?

For now i use :

$solrSearch = new eZSolr();

$search = $solrSearch->search( $query, $params );

Thank everyone !

Technically it works but $search will be an array. Of course i could manipulate this array to outpout a formatted json string but is there something simpler & quicker ?

For exemple could i use this function which seems to operate at a lower level :

$solrSearch = new eZSolreZSolrBase();


Wednesday 09 June 2010 12:11:55 pm

Manipulate the array seems the best choice to me. Could be as simple as

echo json_encode( $search )

Wednesday 09 June 2010 5:57:02 pm

When using the eZSolrBase->rawSolrRequest function you can issue a third parameter which specifies the response format ... which can be json instead of the default "php" (which is a PHP array)

 eZSolrBase->rawSolrRequest($request, $params, 'json')

That saves the json_encode step

The same is true when you use the rawSearch method (where the response format is the second argument)



Modified on Wednesday 09 June 2010 5:57:29 pm by Paul Borgermans


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from