Skip to main content

Quick tips: Inspecting a Solr Document

An article from ComputerMinds - Building with Drupal in the UK since 2005
22nd Feb 2011

Steven Jones

Senior Developer
Steven Jones
Hey, you seem to look at this article a lot! Why not Bookmark this article so you can find it easily in the future?

Another quick tip here: if you're working with the Apache Solr module, specifically looking at the documents that are being created from your nodes, and you want to print out the document and have a look at what fields and values are on your $document then if you did this:


// Print the $document using the devel dpm function.
dpm($document);

Then you would get a very unhelpful output from Krumo, because all the fields on the $document are protected, and so the devel module can't access them. Instead you can do this:


dpm(array_combine($document->getFieldNames(), $document->getFieldValues()));

And you'll get a nice array of field names mapped to their values.

Hi, thanks for reading

ComputerMinds are the UK’s Drupal specialists with offices in Bristol and Coventry. We offer a range of Drupal services including Consultancy, Development, Training and Support. Whatever your Drupal problem, we can help.