• Resolved adcadesigns

    (@adcadesigns)


    Hello how do we create search for ACF Relationship specific for that post

    example: a mall with relationship of shop and Restaurants, search should only be related to what is selected

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I guess I’m not managing to envision what the expected results of a search would be here.

    Like you search “Twin Pines Mall” and it shows results of businesses that have locations in that location?

    Thread Starter adcadesigns

    (@adcadesigns)

    Hello Michael, its the other way around, example im in a specific mall, like “Twin Pines Mall”, then i tried to search for specific shop like “Nike Store” if there is a Nike on that Mall, then it should show up. This should be based on ACF relationship. If that makes sense. Thank you

    Edit: By the way we are using Headless for this thats why we go with algolia.

    • This reply was modified 10 months, 2 weeks ago by adcadesigns.
    Thread Starter adcadesigns

    (@adcadesigns)

    I hope anyone can help please. thank you.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Thank you for your patience over the holiday weekend in the US.

    Best idea I have would be to store the related items as their own property, similar to how we have some of the taxonomy data stored on objects, and set that property to be searchable.

    We have some information at our Wiki about this overall topic. https://github.com/WebDevStudios/wp-search-with-algolia/wiki/Advanced-Custom-Fields

    The biggest thing is that these aren’t going to necessarily be simple string fields, so you’ll need to fetch them and concatenate them into an array and index the array to Algolia.

    Thread Starter adcadesigns

    (@adcadesigns)

    Thank you for your reply Michael, Im fairly new to Algolia, but thank you for the reference, let me check on that and get back to you once i progress.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Basically you need to get the related items as part of the indexed object somehow, and then have that property be one of the properties that gets searched through by a provided query.

    does the instruction in the document only apply to Autocomplete? If so, how do I make it work for Instantsearch?

    The code below is what I have

    add_filter( 'algolia_product_posts_index_settings', 'my_posts_index_settings' );
    // We could also have used a more general hook 'algolia_posts_index_settings',
    // but in that case we would have needed to add a check on the post type
    // to ensure we only adjust settings for the 'speaker' post_type.
    
    /**
    
    @param array $settings
    *
    
    @return array
    */
    function my_posts_index_settings( array $settings ) { // Make Algolia search the 'bio' field when searching for results.
    // Using ordered instead of unordered will make words matching in the beginning of the attribute score higher.
    // @see https://www.algolia.com/doc/api-reference/api-parameters/searchableAttributes/
    $settings['searchableAttributes'][] = 'unordered(product_ingredients)'; // Make Algolia return a pre-computed snippet of 50 chars as part of the result set.
    // @see https://www.algolia.com/doc/api-reference/api-parameters/#highlighting-snippeting
    $settings['attributesToSnippet'][] = 'product_ingredients:50'; // Always return the value we are filtering.
    return $settings;
    }



    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    If you were wanting to target a specific post type for the autocomplete, the filter structure would be:

    algolia_posts_{$post_type}_index_settings

    Note that you have it as, with the post type in the wrong section:

    algolia_product_posts_index_settings

    That said, the index settings filter for Instantsearch is this filter hook name:

    algolia_searchable_posts_index_settings

    There’s no variable hook name for this one as it’s all one index instead of potentially many.

    If you’re wanting to push the index settings for both Autocomplete AND Instantsearch, you’d be able to use both filter names as the content structure is the same.

    Thanks for the clarification.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

    Thread Starter adcadesigns

    (@adcadesigns)

    Hello Michael, can i have 2 different algolia search bar? example one for the general search and the other one is for the specific/filtered search? how do you do that? can we target each? Thank you.

    Also from your answer above my question, do i just do it on algolia settings or do i have to code something?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Howdy, in regards to Autocomplete and inputs, we attach it all via this line from the autocomplete.php template file:

    https://github.com/WebDevStudios/wp-search-with-algolia/blob/2.7.0/templates/autocomplete.php#L156

    document.querySelectorAll( algolia.autocomplete.input_selector ).forEach( function( element ) {
        ....
    }

    That algolia.autocomplete.input_selector value is being set to the following by default:

    input[name='s']:not(.no-autocomplete):not(#adminbar-search)

    We have the algolia_autocomplete_input_selector WordPress filter that you can use to change the selector to whatever you want.

    That said, based on the default selector, you should also be able to disable autocomplete on a field by simply applying the .no-autocomplete class to the field.

    These aren’t things that would be getting set via your index settings in algolia.com, it’d be all code on the WordPress side.

    We don’t have a way to disable a specific search field from the instantsearch results though.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @adcadesigns did my last reply help at all?

    Thread Starter adcadesigns

    (@adcadesigns)

    Thank you Michael for getting back to me, I’m still struggling with alogia. so I switch to a different search service in the meantime.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Understood on all parts there. Perhaps it’ll get a second look in the future, but definitely understand if you’ll just stick with the new one you landed on for any further work as well.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘ACF relationship’ is closed to new replies.