Just tried to add this line in class-wp-solr.php:917 just before the return $doc1;
$doc1 = apply_filters( ‘wp_solr_plugin_filter_doc1’, $doc1, $updateQuery, $opt, $post, $attachment_body );
And this function in my theme functions.php
function sv_wp_solr_plugin_filter_doc1( $doc1, $updateQuery, $opt, $post, $attachment_body )
{
$doc1->testing = “MyTest”;
return $doc1;
}
add_filter(‘wp_solr_plugin_filter_doc1’, ‘sv_wp_solr_plugin_filter_doc1’, 10, 5 );
And its working (have to add testing to the solr schema offcource).
I dont know what all the variables to the create_solr_document_from_post_or_attachment function is doing, so i just added all of them if i need them.
Hope you can add something like this to the plugin. : -)
Regards,
Casper
Plugin Author
WPSOLR
(@wpsolr)
Thanks.
That’s a good idea indeed.
But the data you intend to add to the index must be part of the current schema, or I must extend the current schema. Else you’ll be stuck for ever to merge your schema and WPSOLR schema.
For instance, if your data is a custom field, it is already indexed and can be displayed as a facet.
If someone is extending the plugin via filters, they probably got access to the schema and knows what they are doing. I think the custom posts and facets you already made in the plugin are awesome. This is only for really specific use.
I installed a fresh install of solr5 and they got a managed schema, so solr just adds the new field based on the datatype when i add more to $doc1.
e.g the $doc1->testing showed up automatically without a schema change, when i runned the code above.
You could make a solr5 version of the plugin, where people dont need to make any schema changes.
Regards,
Casper
Plugin Author
WPSOLR
(@wpsolr)
I agree.
If one is aware of the consequences, a filter is great indeed.
Do you have an urgent need for WPSOLR’s filter ? I’d rather package it with the next release.
Im going to production this week, but i just use my own line. Can i subscribe to get a mail when there is a new release?
Or you can write in this thread, if you would like me to test the filters.
Thanks for the quick answers!
Regards,
Casper
Plugin Author
WPSOLR
(@wpsolr)
I’ll get you updated indeed.