WebDevStudios / wp-search-with-algolia

Improve search on your site. Autocomplete is included, along with full control over look, feel and relevance.
https://wordpress.org/plugins/wp-search-with-algolia/
138 stars 54 forks source link

The page post type doesn't show in dropdown, however results are returned from Algolia. The Program post type shows as expected. #403

Closed jamespaulsandel closed 2 months ago

jamespaulsandel commented 4 months ago

Describe the bug The page post type doesn't show as exptected in dropdown, however results are returned from Algolia. The Program post type shows as expected.

To Reproduce Steps to reproduce the behavior: From dev.usa.edu Enter search term. I've been testing with the search phrase "MS-SLP " In the Network console, I can see that results are being returned from Algolia. Dropdown shows only programs. No pages are shown. If I search "MS-SLP a" a page shows up in the dropdown, however results are returned from Algolia for pages with "MS-SLP". On my custom search page "MS-SLP" shows pages and programs. Only the dropdown is the issue. Expected behavior Results from Algolia, including page, should show in the dropdown.

Screenshots image In this screenshot, you can set a result returned by Algolia. The dropdown closes (even with debug: true) so I can't get a screenshot, but it only showed one program, no pages.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

jamespaulsandel commented 4 months ago

FYI: I'm using the the plugins autocomplete.php

tw2113 commented 4 months ago

Can you set SCRIPT_DEBUG to true in this install? That'll help keep the autocomplete dropdown showing even when clicking away. It'll help with some troubleshooting.

I am seeing that you have both posts_program and posts_page enabled in the autocomplete settings.

I am also seeing that there are page results in the POST requests and at least at the moment, I'm only seeing page no program, which is a little confusing, I will actively admit.

To be certain, the only things you've done thus far are UI based, where you clicked the checkbox to enable Autocomplete, and clicked to index the Programs and Pages. I assume you pushed the content to the index as well?

Nothing else code wise has been touched or customized? I am noting you saying you're using the out-of-box autocomplete.php and that's checking out for me.

jamespaulsandel commented 4 months ago

thanks for the response! I have set SCRIPT_DEBUG, WP_DEBUG to true in wp-config.php and in autocomplete.php. For testing, I had reverted autocomplete.php to the default. That didn't solve anything. I'm currently using a custom autocomplete.php. I'll paste that below. I haven't edited the plugin code at all.

So, results are returned by Algolia but not rendered by the plugin. What could cause this?

image

<?php
/**
 * WP Search With Algolia autocomplete template file.
 *
 * @author  WebDevStudios <contact@webdevstudios.com>
 * @since   1.0.0
 *
 * @version 2.5.3
 * @package WebDevStudios\WPSWA
 */

?>

<script type="text/html" id="tmpl-autocomplete-header">
    <div class="autocomplete-header">
        <div class="autocomplete-header-title">{{{ data.label }}}</div>
        <div class="clear"></div>
    </div>
</script>

<script type="text/html" id="tmpl-autocomplete-post-suggestion">
    <a class="suggestion-link" href="{{ data.permalink }}" title="{{ data.post_title }}">
        <# if ( data.images.thumbnail ) { #>
            <img class="suggestion-post-thumbnail" src="{{ data.images.thumbnail.url }}" alt="{{ data.post_title }}">
        <# } #>
        <div class="suggestion-post-attributes">
            <span class="suggestion-post-title">{{{ data._highlightResult.post_title.value }}}</span>
            <# if ( data._snippetResult['content'] && data._snippetResult['content'].value.length > 3 ) { #>
                <span class="suggestion-post-content">{{{ data._snippetResult['content'].value }}}</span>
            <# } else if( data.intro_copy ) { #>
                <span class="suggestion-post-content">{{{ data.intro_copy }}}</span>
            <# } else if( data.body_copy) { #>
                <span class="suggestion-post-content">{{{ data.body_copy.substr(0, 100) }}}</span>
            <# } else { #>
                <span class="suggestion-post-content">{{{ data.post_title }}}</span>
            <# } #>
        </div>
        <?php
        do_action( 'algolia_autocomplete_after_hit' );
        ?>
    </a>
</script>

<script type="text/html" id="tmpl-autocomplete-term-suggestion">
    <a class="suggestion-link" href="{{ data.permalink }}" title="{{ data.name }}">
        <svg viewBox="0 0 21 21" width="21" height="21">
            <svg width="21" height="21" viewBox="0 0 21 21">
                <path
                    d="M4.662 8.72l-1.23 1.23c-.682.682-.68 1.792.004 2.477l5.135 5.135c.7.693 1.8.688 2.48.005l1.23-1.23 5.35-5.346c.31-.31.54-.92.51-1.36l-.32-4.29c-.09-1.09-1.05-2.06-2.15-2.14l-4.3-.33c-.43-.03-1.05.2-1.36.51l-.79.8-2.27 2.28-2.28 2.27zm9.826-.98c.69 0 1.25-.56 1.25-1.25s-.56-1.25-1.25-1.25-1.25.56-1.25 1.25.56 1.25 1.25 1.25z"
                    fill-rule="evenodd"></path>
            </svg>
        </svg>
        <span class="suggestion-post-title">{{{ data._highlightResult.name.value }}}</span>
    </a>
</script>

<script type="text/html" id="tmpl-autocomplete-user-suggestion">
    <a class="suggestion-link user-suggestion-link" href="{{ data.posts_url }}" title="{{ data.display_name }}">
        <# if ( data.avatar_url ) { #>
            <img class="suggestion-user-thumbnail" src="{{ data.avatar_url }}" alt="{{ data.display_name }}">
        <# } #>
        <span class="suggestion-post-title">{{{ data._highlightResult.display_name.value }}}</span>
    </a>
</script>

<script type="text/html" id="tmpl-autocomplete-footer">
    <div class="autocomplete-footer">
        <div class="autocomplete-footer-branding">
            <a href="#" class="algolia-powered-by-link" title="Algolia">
                <svg width="150px" height="25px" viewBox="0 0 572 64"><path fill="#36395A" d="M16 48.3c-3.4 0-6.3-.6-8.7-1.7A12.4 12.4 0 0 1 1.9 42C.6 40 0 38 0 35.4h6.5a6.7 6.7 0 0 0 3.9 6c1.4.7 3.3 1.1 5.6 1.1 2.2 0 4-.3 5.4-1a7 7 0 0 0 3-2.4 6 6 0 0 0 1-3.4c0-1.5-.6-2.8-1.9-3.7-1.3-1-3.3-1.6-5.9-1.8l-4-.4c-3.7-.3-6.6-1.4-8.8-3.4a10 10 0 0 1-3.3-7.9c0-2.4.6-4.6 1.8-6.4a12 12 0 0 1 5-4.3c2.2-1 4.7-1.6 7.5-1.6s5.5.5 7.6 1.6a12 12 0 0 1 5 4.4c1.2 1.8 1.8 4 1.8 6.7h-6.5a6.4 6.4 0 0 0-3.5-5.9c-1-.6-2.6-1-4.4-1s-3.2.3-4.4 1c-1.1.6-2 1.4-2.6 2.4-.5 1-.8 2-.8 3.1a5 5 0 0 0 1.5 3.6c1 1 2.6 1.7 4.7 1.9l4 .3c2.8.2 5.2.8 7.2 1.8 2.1 1 3.7 2.2 4.9 3.8a9.7 9.7 0 0 1 1.7 5.8c0 2.5-.7 4.7-2 6.6a13 13 0 0 1-5.6 4.4c-2.4 1-5.2 1.6-8.4 1.6Zm35.6 0c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1-1.3 1.7-2.2 1l-19.2-17a18 18 0 0 1-11 3.4 18.1 18.1 0 1 1 18.2-14.8c-.1.4-.5.7-.9.6-.1 0-.3 0-.4-.2l-3.8-3.4c-.4-.3-.6-.8-.7-1.4a12 12 0 1 0-2.4 8.3c.4-.4 1-.5 1.6-.2l14.7 13.1v-46H323a26 26 0 1 0 10 49.7c.8-.4 1.6-.2 2.3.3l3 2.7c.3.2.3.7 0 1l-.2.2a32 32 0 0 1-47.2-28.6z"></path></svg>
            </a>
        </div>
    </div>
</script>

<script type="text/html" id="tmpl-autocomplete-empty">
    <div class="autocomplete-empty">
        <?php esc_html_e( 'No results matched your query ', 'wp-search-with-algolia' ); ?>
        <span class="empty-query">"{{ data.query }}"</span>
    </div>
</script>

<script type="text/javascript">
    window.addEventListener('load', function () {

        /* Initialize Algolia client */
        var client = algoliasearch( algolia.application_id, algolia.search_api_key );

        /**
         * Algolia hits source method.
         *
         * This method defines a custom source to use with autocomplete.js.
         *
         * @param object $index Algolia index object.
         * @param object $params Options object to use in search.
         */
        var algoliaHitsSource = function( index, params ) {
            return function( query, callback ) {
                index
                    .search( query, params )
                    .then( function( response ) {
                        callback( response.hits, response );
                    })
                    .catch( function( error ) {
                        callback( [] );
                    });
            }
        }

        /* Setup autocomplete.js sources */
        var sources = [];
        algolia.autocomplete.sources.forEach( function( config, i ) {
            var suggestion_template = wp.template( config[ 'tmpl_suggestion' ] );
            sources.push( {
                source: algoliaHitsSource( client.initIndex( config[ 'index_name' ] ), {
                    hitsPerPage: config[ 'max_suggestions' ],
                    attributesToSnippet: [
                        'modules_0_wysiwyg'
                    ],
                    highlightPreTag: '__ais-highlight__',
                    highlightPostTag: '__/ais-highlight__'
                } ),
                templates: {
                    header: function () {
                        return wp.template( 'autocomplete-header' )( {
                            label: _.escape( config[ 'label' ] )
                        } );
                    },
                    suggestion: function ( hit ) {
                        if ( hit.escaped === true ) {
                            return suggestion_template( hit );
                        }
                        hit.escaped = true;

                        for ( var key in hit._highlightResult ) {
                            /* We do not deal with arrays. */
                            if ( typeof hit._highlightResult[ key ].value !== 'string' ) {
                                continue;
                            }
                            hit._highlightResult[ key ].value = _.escape( hit._highlightResult[ key ].value );
                            hit._highlightResult[ key ].value = hit._highlightResult[ key ].value.replace( /__ais-highlight__/g, '<em>' ).replace( /__\/ais-highlight__/g, '</em>' );
                        }

                        for ( var key in hit._snippetResult ) {
                            /* We do not deal with arrays. */
                            if ( typeof hit._snippetResult[ key ].value !== 'string' ) {
                                continue;
                            }

                            hit._snippetResult[ key ].value = _.escape( hit._snippetResult[ key ].value );
                            hit._snippetResult[ key ].value = hit._snippetResult[ key ].value.replace( /__ais-highlight__/g, '<em>' ).replace( /__\/ais-highlight__/g, '</em>' );
                        }
                        console.log(hit)

                        return suggestion_template( hit );
                    }
                }
            } );

            console.log(sources)
        } );

        /* Setup dropdown menus */
        document.querySelectorAll( algolia.autocomplete.input_selector ).forEach( function( element ) {

            var config = {
                debug: true,
                hint: false,
                openOnFocus: true,
                appendTo: 'body',
                templates: {
                    empty: wp.template( 'autocomplete-empty' )
                }
            };

            if ( algolia.powered_by_enabled ) {
                config.templates.footer = wp.template( 'autocomplete-footer' );
            }

            /* Instantiate autocomplete.js */
            var autocomplete = algoliaAutocomplete( element, config, sources )
                .on( 'autocomplete:selected', function ( e, suggestion ) {
                    /* Redirect the user when we detect a suggestion selection. */
                    window.location.href = suggestion.permalink ?? suggestion.posts_url; // Users use the `posts_url` property instead of `permalink`.
                } );

            jQuery(window).on("scroll", function() {
                if(jQuery(window).scrollTop() > 0) {
                    var query = jQuery(".searchform:nth(0) .input-group:nth(0) input:nth(0)").val()
                    jQuery(".searchform:nth(1) .input-group:nth(0) input:nth(0)").val(query)    
                    autocomplete.autocomplete.setVal(query)
                    jQuery(".searchform:nth(1) .input-group:nth(0) label:nth(0)").click()
                } else {
                    var query = jQuery(".searchform:nth(1) .input-group:nth(0) input:nth(0)").val()
                    jQuery(".searchform:nth(0) .input-group:nth(0) input:nth(0)").val(query)    
                    autocomplete.autocomplete.setVal(query)
                    jQuery(".searchform:nth(0) .input-group:nth(0) label:nth(0)").click()
                }

                if ( autocomplete.autocomplete.getWrapper().style.display === "block" ) {
                    //autocomplete.autocomplete.close();
                    //autocomplete.autocomplete.open();
                }
                jQuery(document).on("click", (ev) => {
                    if($(ev.target).closest("input[name=s], label").length === 0) {
                        jQuery(window).unbind("scroll")
                        jQuery(document).trigger("load")

                    }
                })  
            } );
        } );

        var algoliaPoweredLink = document.querySelector( '.algolia-powered-by-link' );
        if ( algoliaPoweredLink ) {
            algoliaPoweredLink.addEventListener( 'click', function( e ) {
                e.preventDefault();
                window.location = "https://www.algolia.com/?utm_source=WordPress&utm_medium=extension&utm_content=" + window.location.hostname + "&utm_campaign=poweredby";
            } );
        }
    });
</script>
jamespaulsandel commented 4 months ago

autocomplete.txt

jamespaulsandel commented 4 months ago

this file is named autocomplete.php, but I couldn't upload a php file, so I've uploaded it as text.

tw2113 commented 4 months ago

Hi again,

We should definitely get an established baseline figured out, which would be with using the default template coming from the plugin's template folder. If/when we establish that that's working as expected, we can start checking on what changes from the customized autocomplete.php may be affecting things. For example that jQuery scroll event listening is looking curious.

So, results are returned by Algolia but not rendered by the plugin. What could cause this?

Definitely the biggest question.

Have you done a lot of index configuration changes via your algolia.com dashboard? It's possible that is affecting things as well. Something feels like it's definitely changed since yesterday since even a search for "MS-SLP" like originally mentioned, now returns no results.

jamespaulsandel commented 4 months ago

Thanks for working on this with me. . I've uninstalled / reinstalled the plugin. I've deleted the algolia folder from my theme. I've reindexed. The settings at Algolia for the Page post type are identical to the settings for my other post types.

I think we can rule out settings at Algolia, as the results are being returned. They're just not being rendered.

I've noticed that a search for "n" will show show pages. A search for "nursing" will not, even though one of the results returned by Algolia has the page title "School of Nursing — Nursing Programs". It's just not rendered. Any other ideas?

jamespaulsandel commented 4 months ago

also, I developed a search.php that uses the settings provided by this plugin and makes its own calls to Algolia. The results on the search page appear as expected.

tw2113 commented 4 months ago

All of this comment is going to be with probably the custom search.php in place still. Which is why I'm kind of asking to put everything back in default state so I can troubleshoot effectively.

Definitely understood what you've tried thus far. Still kind of trying to get things to a state where I can look things over without things changing too much in the background, for troubleshooting sake.

For example, your comment about typing "n" into the search box.

I went back to dev.usa.edu and did the same.

Based on what I'm presently seeing, you have 6 different post types toggled for Autocomplete, in the following order

  1. program
  2. page
  3. tribe_events
  4. faculty
  5. administration
  6. post

Each provided 5 results.

When I added in an "o" to spell "no", programs went down to 1 result, page stayed at 5 and showed various "apply now" results. Events still has 5, faculty has 1, administration has zero, and post has 5.

It's potentially pretty hard to tell at times because it's potentially showing a dropdown of 30 results sectioned off by content type. I had to zoom my window to 50% to see it all. So to certain degrees, at least with my current testing, it's returning and rendering results.

WP Search with Algolia settings

That said, in terms of the WP Search with Algolia plugin, there's only a certain amount of settings that we provide UI for. Enabling autocomplete/integrated search/instantsearch, and then with autocomplete specifically, which content types to index, amount of items to show, and order in which to show when multiple are chosen. Then there's UI to re-index and push code-based customization settings(something I don't believe has been used by you thus far).

Configuration methods.

There's also your configuration dashboard that I suspect you have been using more, see at example urls like https://dashboard.algolia.com/apps/MY_APP_ID/explorer/configuration/wp_posts_post/ where you can tweak relevance essentials/optimizations, filtering/faceting details, and search behavior among other things.

Those are details that we can't see from the plugin directly, but very much could be getting applied to returned results.

If you were to do code-based customizations of settings, for which we have documentation on, the "push settings" button would be what sends those customizations to this configuration tab. If you've made configuration edits via the algolia.com url examples above, I recommend not pressing this button as it would overwrite the values.

Why I bring up the configuration

Without knowing what's been done in the dashboard and the configuration tab, it's hard for me to say what behavior changes may be being applied to your returned results, as well as weights given to potentially individual items in the index. That said, at the moment it's seeming to be returning what it thinks would be the most relevant

That said

At the exact moment still, I'm typing in a search for USAHS and it's showing me the posts section, but not the pages section in a dropdown format, despite both returning 5 results, so part of me is still at a loss.

tw2113 commented 4 months ago

@jamespaulsandel any news or new information regarding this?

jamespaulsandel commented 4 months ago

Hi Michael,

Thanks for the follow up. I wasn't able to determine why pages stopped showing. Configurations within Wordpress and Algolia seemed corrected. I'd reinstalled the plugin after manually deleting related options in the databasse. It didn't appear cache related.

I ended up putting together a custom plugin built on instantsearchjs and the php client. The project is moving along well.

On Thursday, March 21st, 2024 at 3:32 PM, Michael Beckwith @.***> wrote:

@.***(https://github.com/jamespaulsandel) any news or new information regarding this?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

tw2113 commented 4 months ago

Totally understood on having to take a route that gets the best result. While of course I enjoy helping others with our plugin as much as possible, I'm happier knowing you're sticking with Algolia as a whole.

tw2113 commented 2 months ago

Closing this as a non issue for the moment.