• Resolved Michael Oswald

    (@malerwhick)


    The excerpt will not be added to the solr index, in that way you cannot search for any of its information.

    The field post_excerpt could hold additional information to an post, that completely differs that in post_content.
    So, in my understanding, to get a accurate search result for posts, the excerpt should be added.

    All details of the changes i had to made to add the excerpt to the solr index are in this SVN diff.

    Index: solr/wpsolr-index-solr-client.php
    ===================================================================
    — solr/wpsolr-index-solr-client.php (revision 2562)
    +++ solr/wpsolr-index-solr-client.php (working copy)
    @@ -484,6 +484,7 @@
    // Post is NOT an attachment: we get the document body from the post object
    $pcontent = $post_to_index->post_content;
    }
    + $pexcerpt = $post_to_index->post_excerpt;
    $pauth_info = get_userdata( $post_to_index->post_author );
    $pauthor = isset( $pauth_info ) ? $pauth_info->display_name : ”;
    $pauthor_s = isset( $pauth_info ) ? get_author_posts_url( $pauth_info->ID, $pauth_info->user_nicename
    ) : ”;
    @@ -575,6 +576,8 @@

    // Remove HTML tags
    $solarium_document_for_update[ WpSolrSchema::_FIELD_NAME_CONTENT ] = strip_tags( $content_with_shortcodes_expanded_or_stripped
    );
    +
    + $solarium_document_for_update[ WpSolrSchema::_FIELD_NAME_EXCERPT ] = $pexcerpt;

    $solarium_document_for_update[ WpSolrSchema::_FIELD_NAME_AUTHOR ] = $pauthor;
    $solarium_document_for_update[ WpSolrSchema::_FIELD_NAME_AUTHOR_S ] = $pauthor_s;

    Index: wpsolr-schema.php
    ===================================================================
    — wpsolr-schema.php (revision 2562)
    +++ wpsolr-schema.php (working copy)
    @@ -15,6 +15,7 @@
    const _FIELD_NAME_PID = ‘PID’;
    const _FIELD_NAME_TITLE = ‘title’;
    const _FIELD_NAME_CONTENT = ‘content’;
    + const _FIELD_NAME_EXCERPT = ‘excerpt’;
    const _FIELD_NAME_AUTHOR = ‘author’;
    const _FIELD_NAME_AUTHOR_S = ‘author_s’;
    const _FIELD_NAME_TYPE = ‘type’;

    https://www.ads-software.com/plugins/wpsolr-search-engine/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘the post_excerpt is not part of the index’ is closed to new replies.