Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Association search not functioning as expected for large # of entries with body text #74

Open
tonyketcham opened this issue Dec 18, 2020 · 1 comment

Comments

@tonyketcham
Copy link

tonyketcham commented Dec 18, 2020

Context

We have successfully used the association field to embed content type taxonomies (videos, photo galleries) of which there are a few thousand entries - search results are quite snappy and provide pleasant UX.

However, using the association field to embed articles inside other articles (of which there are 30-60k+ per site), the search feature returns undesirable results 9 times out of 10. My guess is that the search field is perhaps trying to compare keywords to the body content of every article in the 30k+ entries, rather than just the titles? I could be wrong in that assumption.

The search lags very intensely for articles, where the bulk of the time it returns segmented iterations of results, none of which have any relation to the query.

Undesired current article block search

Screen Recording 2020-12-18 at 3 36 08 PM

Working example with Video Block

Although videos often have body text as well (much less than articles) the search works just fine
Screen Recording 2020-12-18 at 3 46 46 PM

However, while still quite slow for the articles...

This specific query was found to return some expected results

image

As does the video block

image

Desired outcome

I'm looking for a way to have the search feature strictly compare to the post taxonomy (our articles) title content, and return relevant results. Could I perhaps specify something in the association query to compare the search query to ONLY the post title?

Currently...

        Field::make('association', 'gnl_article_embed', __('Article'))
            ->set_types(array(
                array(
                    'type'          => 'post',
                    'post_type'     => 'post',
                ),
            ))

Respective code

Video Block

Block::make(__('Video Embed'))
  ->add_fields(array(
    Field::make('html', 'video_information_text')
      ->set_html('<h2>Video Embed</h2><p><span style="color: red">Please note:</span> The video has to be published to the sites that this article is published to for the video to show up in the article</p>'),
    Field::make('association', 'gnl_video_embed', __('Video'))
      ->set_types(array(
        array(
          'type'      => 'post',
          'post_type' => 'gnl_videos',
        )
      ))
      ->set_min(1)
      ->set_max(1)

  ))
  ->set_category('gnl_blocks', __('Blocks by <Company Name>'), '')
  ->set_icon('video-alt2')
  ->set_preview_mode(true)
  ->set_render_callback(function ($video_block) { ... });
...

Article Block

Block::make(__('Article Embed'))
    ->add_fields(array(
        Field::make('html', 'article_information_text')
            ->set_html('<h2>Article Embed</h2><p><span style="color: red">Please note:</span> The embedded article has to be published to the sites that this post is published to for the embedded article to show up in this post</p>'),
        Field::make('association', 'gnl_article_embed', __('Article'))
            ->set_types(array(
                array(
                    'type'          => 'post',
                    'post_type'     => 'post',
                ),
            ))
            ->set_min(1)
            ->set_max(1)

    ))
    ->set_category('gnl_blocks', __('Blocks by <Company Name>'), '')
    ->set_icon('media-document')
    ->set_preview_mode(true)
    ->set_render_callback(function ($article_block) { ... });
...
@tonyketcham
Copy link
Author

We're using
Carbon Fields version - [3.1]
WP - [5.2]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant