Forum Replies Created
-
wpsolrKeymaster7 years, 10 months ago in reply to: Building a custom facet from an ACF post type relationship #8689
The new field must be one of the fields selected in 2.2.
Make it appear in 2.2 with the code below, then select it with its type:
add_filter( WPSOLR_Events::WPSOLR_FILTER_INDEX_CUSTOM_FIELDS, [ $this, 'add_my_field_to_indexed_custom_fields', ], 10, 2 );/** * Add a field to indexed fields in 2.2 * * @param string[] $custom_fields * @param string $model_type * * @return array */ public function add_my_field_to_indexed_custom_fields( $custom_fields, $model_type ) { if ( ! isset( $custom_fields ) ) { $custom_fields = []; } switch ( $model_type ) { case 'post': case 'page': // add other post types if you like if ( ! in_array( 'my-field-name', $custom_fields, true ) ) { array_push( $custom_fields, 'my-field-name' ); } break; } return $custom_fields; }wpsolrKeymaster7 years, 10 months ago in reply to: Building a custom facet from an ACF post type relationship #8688Can I see the new hook code?
wpsolrKeymaster7 years, 10 months ago in reply to: Building a custom facet from an ACF post type relationship #8686It does not appear in the index?
wpsolrKeymaster7 years, 10 months ago in reply to: Building a custom facet from an ACF post type relationship #8684What does not work?
wpsolrKeymaster7 years, 10 months ago in reply to: Building a custom facet from an ACF post type relationship #8682The name of the indexed field is “writers”.
This is not a predefined field in the index schema, nor a dynamic type field. It is therefore not recognized by ES / Solr (there must be error messages in their log).
You have to give a dynamic type to the field. Use “writers_str” should do it.
wpsolrKeymaster7 years, 10 months ago in reply to: Building a custom facet from an ACF post type relationship #8680Can I see the code?
wpsolrKeymaster7 years, 10 months ago in reply to: Building a custom facet from an ACF post type relationship #8678The custom fields appear in 2.2 if they are used (enter a value in a post for example).
Or if they are an ACF custom field, a WooCommerce attribute.
Otherwise, to make them appear:
WPSOLR_Events::WPSOLR_FILTER_INDEX_CUSTOM_FIELDS
(used in WooCommerce, ACF, … to add custom fields in screen 2.2).wpsolrKeymaster7 years, 10 months ago in reply to: Building a custom facet from an ACF post type relationship #8676Do not hesitate to add a topic to /forums/forum/technical-configuration-issues/actions-and-filters/
Others will appreciate some concrete examples.
wpsolrKeymaster7 years, 10 months ago in reply to: Building a custom facet from an ACF post type relationship #8675Yes, I have just been told that WpSolrFilters was obsolete.
wpsolrKeymaster7 years, 10 months ago in reply to: Building a custom facet from an ACF post type relationship #8673In your case, the easiest way is to “denormalize” during indexing “.
see /guide/actions-and-filters/index-modify-custom-fields/
At the time of indexing:
=> for each post, find the authors, and fill a field meta ‘_author_nice_name’ of the post (multi-value) with the “first name + name”.
=> configure this field in screens 2.2, 2.4
The rest is done automatically by WPSOLR.
I’ve copied an example from the s2Member extension that deserializes a field before indexing.add_filter( WPSOLR_Events::WPSOLR_FILTER_POST_CUSTOM_FIELDS, [ $this, 'filter_custom_fields' ], 10, 2 );/** * Filter custom field self::CUSTOM_FIELD_NAME_STORING_POST_CAPABILITIES of a document * * s2Member serialize capabilities of the post * ex: a:2:{i:0;s:25:"capability1";i:1;s:25:"capability2";} * * We must unserialize it * ex: ['capability1', 'capability2'] * * @param $custom_fields array Serialized array of capabilities * * return array Custom fields with unserialized array of capabilities in self::CUSTOM_FIELD_NAME_STORING_POST_CAPABILITIES */ public function filter_custom_fields( $custom_fields, $post_id ) { // Remove the WpSolrSchema::_SOLR_DYNAMIC_TYPE_STRING at the end of the custom field $custom_field_name = str_replace( WpSolrSchema::_SOLR_DYNAMIC_TYPE_STRING, '', self::CUSTOM_FIELD_NAME_STORING_POST_CAPABILITIES ); if ( $custom_fields && count( $custom_fields ) > 0 ) { if ( isset( $custom_fields[ $custom_field_name ] ) ) { $serialized_custom_field_array = $custom_fields[ $custom_field_name ]; if ( $serialized_custom_field_array ) { // Field is serialiezd by s2Member; unserialize it before indexing $custom_fields[ $custom_field_name ] = unserialize( $serialized_custom_field_array[0] ); } } } /* is_protected_by_s2member returns, after debugging: - false - or [s2member_level_req => i] is the level i (0, 1, 2, 3, 4) is set on the post - or [s2member_ccap_req => capability1] if capability1 is the first capability on the post Very different from what is described in the documentation !!! */ // levels used as filters too $protections = is_protected_by_s2member( $post_id ); $level = null; if ( is_array( $protections ) ) { if ( isset( $protections[ self::CUSTOM_FIELD_NAME_STORING_POST_LEVEL ] ) ) { // level is an integer >= 0 $level = $protections[ self::CUSTOM_FIELD_NAME_STORING_POST_LEVEL ]; // Add level to custom fields, as it should have been done $custom_fields[ $custom_field_name ][] = $level; } } return $custom_fields; }wpsolrKeymaster7 years, 10 months ago in reply to: Building a custom facet from an ACF post type relationship #8671Hi,
Relationship fields have been set aside for the moment, because frankly I do not know what to do in terms of search or filters.
If you have specs, I’m interested!
wpsolrKeymaster7 years, 10 months ago in reply to: Error saving existing index configuration #8669You need to create a new index (change the path: /solr/another-name-here), to see the commands to execute on your Solr server.
Your current index is misconfigured somehow.
wpsolrKeymaster7 years, 10 months ago in reply to: Error saving existing index configuration #8667You must install the configuration files for your index. Commands are listed with the index settings.
/guide/video-gallery-create-index/video-create-apache-solr-index-semi-automatically/
wpsolrKeymaster7 years, 10 months ago in reply to: Error saving existing index configuration #8665Are you mentioning the index screen ?
What is the error message ?
Anything in your debug.log ?
wpsolrKeymaster7 years, 10 months ago in reply to: Download invoices #8661Hi,
The billing is managed by 2checkout.com
You should have received emails from 2checkout, with a link to your 2checkout account. From your account, you can then download your invoices.
But you should already have been e-mailed your invoices.