Skip to main content
ComputerMinds

Quick tips: Inspecting a Solr Document

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:

Steven Jones · 1 min read

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:

<code class="language-php hljs">
// Print the $document using the devel dpm function.
dpm($document);
</code>

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:

<code class="language-php hljs">
dpm(array_combine($document->getFieldNames(), $document->getFieldValues()));
</code>

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