Challenging one for someone smart out there! Search bar not working anymore

Hi all!

I recently created a custom liquid search bar:

{{ 'template-collection.css' | asset_url | stylesheet_tag }}
{{ 'component-card.css' | asset_url | stylesheet_tag }}
{{ 'component-price.css' | asset_url | stylesheet_tag }}
{{ 'component-search.css' | asset_url | stylesheet_tag }}

{%- if section.settings.enable_filtering or section.settings.enable_sorting -%}
  {{ 'component-facets.css' | asset_url | stylesheet_tag }}
  
{%- endif -%}

{%- liquid
  assign sort_by = search.sort_by | default: search.default_sort_by
  assign terms = search.terms | escape
  assign search_url = '?q=' | append: terms | append: '&options%5Bprefix%5D=last&sort_by=' | append: sort_by
-%}

{%- style -%}
  .section-{{ section.id }}-padding {
    padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
    padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
  }

  @media screen and (min-width: 750px) {
    .section-{{ section.id }}-padding {
      padding-top: {{ section.settings.padding_top }}px;
      padding-bottom: {{ section.settings.padding_bottom }}px;
    }
  }
{%- endstyle -%}

  
    

      # 
        {%- if search.performed -%}
          {{- 'templates.search.title' | t -}}
        {%- else -%}
          {{- 'general.search.search' | t -}}
        {%- endif -%}
      
      
        {%- if settings.predictive_search_enabled -%}
          
        {%- endif -%}

      

      {%- if search.performed -%}
        {%- unless section.settings.enable_filtering or section.settings.enable_sorting -%}
          {%- if search.results_count > 0 -%}
            

{{ 'templates.search.results_with_count_and_term' | t: terms: search.terms, count: search.results_count }}

          {%- endif -%}
        {%- endunless -%}
        {%- if search.results_count == 0 and search.filters == empty -%}
          

{{ 'templates.search.no_results' | t: terms: search.terms }}

        {%- endif -%}
      {%- endif -%}
    

    {%- if search.performed -%}
      {%- if section.settings.enable_sorting and section.settings.filter_type == 'vertical' and search.filters != empty -%}
        
      {%- endif -%}
      

    {%- endif -%}
  

I noticed search bar was working well but I have noticed some issues since I implemented this search bar. The live version of the search bar is not working anymore. FYI, I do not know if this is related to the code above. Just mentioning it as it is something that was done around this time.

I recently uploaded roughly 800 products by scraping another website. They are all there in my backend and configured correctly. When I preview my website from the backend and use the search function it works fine. It displays everything correctly and the count is correct.

However, if I go to the live version online the search doesn’t work. When I search a very broad term like the brand name it shows no results. It does show a count on the page but that is also incorrect.

Even if I delete the custom liquid and revert back to original search bar the issue persists.

It is as though the search results on the live page are not in sync with what is on the actual website…

If I search a very specific full title, the search finds the correct product. I know because I deleted this product from the back end and it is not searchable anymore.

Everything else on the live website is correct and up tp date if I make any changes to the back end.

Any ideas what the issue may be?

Kind regards,

Hey,

Your code look fine, here are some common reason

  1. Indexing Delay: Shopify’s search function relies on an index of your products, which is updated periodically. If you’ve recently added a large number of products, it’s possible that the index hasn’t fully updated yet. This could explain why specific searches work (the product has been indexed) but broader searches do not (not all products have been indexed).

  2. Cache Issue: Sometimes, browser or server caching can cause discrepancies between what you see in the backend and what appears on the live site. Try clearing your browser cache or using a different browser to see if the issue persists.

  3. Theme or App Conflict: If you’re using a custom theme or have installed any apps that modify the search function, they could be causing a conflict. Try disabling these one by one to see if the issue resolves.

  4. Search Algorithm: Shopify’s search function uses an algorithm that might not always return the results you expect, especially for broad terms. It’s designed to return the most relevant results, which might not necessarily include all products that match the search term.

Hi

Thanks for the reponse!

  1. How long would this generally take? This issue has been persisting for about 12 hours so far.

  2. I can rule this one out. Have tried different browsers and incognito mode.

  3. Possibly? I use Stock Sync but this only looks at SKU and then updates inventory at specific locations…

  4. Definitely not this. It was working well before.

Does anyone have any other ideas or something I could try to narrow down what the possible cause could be?

Thanks community!