Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi,
My store has 5 metafields. All of which have been displayed on the storefront.
But the native search from Shopify can only result in the product title / description, collection or articles.
These metafields include valuable data, is there a way to enable search bar to include those data as well?
Thank you.
Solved! Go to the solution
This is an accepted solution.
No. At this point in time Shopify hasn’t exposed metafields to search but there are some search apps that will help.
Now if you have a very small product range you could create your own search tool with Liquid and JavaScript where you loop over all products (let’s say less than 50),check the metafields on each, and then show any that match.
This is an accepted solution.
No. At this point in time Shopify hasn’t exposed metafields to search but there are some search apps that will help.
Now if you have a very small product range you could create your own search tool with Liquid and JavaScript where you loop over all products (let’s say less than 50),check the metafields on each, and then show any that match.
Yes, I'm kinda aware of the situation.
It's hard waiting for a big platform to go around hoops.
But thank you for not recommending another search app and keep the community focus on solely discussion.
Hi,
Just wondering if there is any indication of when Shopify will expose metafields to search?
Having entered a lot of data into metafields only to find out that we have to either re-enter it as tags (doing something twice is never efficient or wise) or use/pay for an add-on app that doesn't look/feel interact like the rest of the paid theme doesn't sit well at all.
I appreciate the scale of the data could be intense but for many storefronts, the data in the metafields is the same amount of data that was previously in the product description or other descriptions (that were 100% searchable).
Launching 2.0 with 'improved' functionality including metafields that aren't searchable seems naïve and very short sighted on Shopify's part. Why would a storefront go to the work of entering data into their store only to have it not be searchable?
Had there been a disclaimer that metafields weren't searchable, we wouldn't have spent weeks migrating to a new theme. We found the issue as a fluke after tons of work had been done. Really disappointing and frustrating. It has completed halted our launch plans.
thx
Hello Jason.
Currently, Shopify added the Metafields system on Settings.
Do you know Shopify search algorithm search content from the new Metafields or not?
Thanks in advance.
Has this since changed? I spent considerable time implementing Metafields on our site, only to discover that they weren't searchable. This sounds like a pretty big oversight on Shopify's part. Has anyone heard whether this is on the roadmap?
Jason - has Shopify exposed metafields to search yet? Is it on the roadmap?
I've been to find Metafield content using our search bar. It may have been related to installing the Search & Discovery app. We've also upgraded to Shopify Plus. Or it could've been the recent Spring update. If anyone would like to test this and update the thread, I think it could be useful for others.
Any update on this? Feels like this such be a native feature.
You can use this app https://apps.shopify.com/ultimate-search-and-filter-1 to enable search by metafields. Once installed, go to the app, App settings => Search index and add your product or variant metafields then hit Sync.
I found a workable solution/workaround to this situation, sortof. It might not work perfectly in your scenario, but I'll leave it here in case someone else can use it for something.
I have a metafield that contains keywords pertaining to the product. I loop over this list to create a link for each keyword, which is displayed at the bottom of my product description. The link takes the customer to the search results for that word. This is both for the customer and for SEO purposes, basically creating a second set of Tags I can show the user, without exposing all the regular/system Tags I use to do internal stuff like sorting posters based on language, dimensions, orientation, etc.
As an example, see the 'KEYWORDS' section in the product description for this alphabet/letter poster in my shop: https://rouxposter.com/products/the-letter-n-a-poster-with-english-n-words
Click on any word in the list, and you'll see that the search results find at least one poster (I haven't implemented the keywords on all my posters yet).
As the keywords are in a metafield, they won't trigger any search results by themselves (sadly). So what I've done is I've added the keywords to the bottom of my product description, preceded by the word 'search-split', e.g.:
(in the product description field)
My product description blah blah blah
search-split my, list, of, keywords, or anything else you want to be searchable but not visible.
In my product-template.liquid, I split the product.description in two by using 'search-split' as the splitting text. I then output the first part of the product description, effectively hiding the keywords from the user, while still letting them be part of the searchable words for this product:
(in product-template.liquid, when outputting the product description)
<!-- ROUX HIDE SEARCH KEYWORDS -->
{% assign hide-search = product.description | split: "search-split" %}
{{ hide-search | first }}
This does require you to add the keywords twice in my specific use-case (both in metafield and in product description), which probably isn't all that clever. While writing this, I realised I don't really need the metafield, I just need to create my links by looping over the second part of 'hide-search'. I ended up dropping the metafield completely and just doing this instead:
<!-- ROUX HIDE SEARCH KEYWORDS -->
{% assign hide-search = product.description | split: "search-split" %}
{{ hide-search | first }}
<!-- ROUX MAKE KEYWORD LINK LIST -->
{% if hide-search.size == 2 %}
{% assign keyword-list = hide-search[1]| split: ', ' %}
<h4>Keywords — click to search</h4>
{% for keyword in keyword-list %}
<a href="/search?type=product&options%5Bprefix%5D=none&q={{keyword}}&options%5Bprefix%5D=last" class="keyword-links" title="click here to search for '{{keyword}}'">{{ keyword }}</a>{% if forloop.last != true %},{% endif %}
{% endfor %}</p>
{% endif %}
Of course, you probably don't need the link list like me, so just skip the second part of the code.
In closing, I've basically made a hack for hiding specific text from the product page while keeping the hidden text searchable, which is probably not useable in most metafield-related cases. I hope someone can still use this for something. Let me know what you think.
Thank you for this. Just like you said, what is the point of using metafields if you have to resort to hacking a default method just to make it work. I think I'm going to try this.
I was horrified to learn this today as well. lol. I had always assumed that under "more filters" there was a way to search by custom metafields. nope.
For all of the Shopify greatness there is an equal amount of absurd shortcomings. I would say 65% of the "apps" out there propose to "fix" things that should be standard features with any shopify store. filtering by multiple tags, searching by metafield, or simple stuff like BULK updates for URLs. We need a way to vote for features
This is a public company now. I own 5 shares of NYSE:SHOP. Not a big player, lol, just a little fry with a Robbinhood account. I have an idea: LETS GET A GROUP TOGATHER OF SHOPIFY USERS WHO ALL HAVE AT LEAST 1 SHARE OF NYSE:SHOP STOCK and then write letters to the investor relations department, they are required by law by the SEC to read written letters from shareholders. This could be a way to show our support (clearly we use the product and own stock, so we are all "part owners") while making sure our voice is being heard.
I'm just chiming in to say that it seems crazy not to have metafield data available in search, given that we can insert those fields to appear on the site itself. In the case of my business, I finally have book authors available as a metafield upon import, but that is utterly useless to me if people cannot search them, and I have too many unique SKUs and authors to apply any of the workarounds mentioned here. Nor do I have the money for an expensive "enhanced search" app. Shopify, please fix this.
Agree they really need to solve this
I fully agree. Metafield data should be available in search. This feature is really needed.
A little late to the party, but you can search for products using their meta fields via the storefront graphql API, here's an example:
query Products {
products(first: 1, query: "metafield:value:<metafield_value>") {
edges {
cursor
node {
description
handle
id
title
metafield(key: "<metafield_key>", namespace: "custom") {
key
namespace
value
}
}
}
}
}
Hi Mechaadi,
Where should we put these codes?
Is it possible to search the variants metafields?
(customer site)
We managed to display it at the storefront but were not able to search.
e.g. varaints.metafields.custom.color
Try using the query format products(first: 1, query: "metafield:'[namespace].[metafield key]':'[value]'")
to filter products based on specific metafield values.
For example, to filter products that have a specific color, you could use:
products(first: 1, query: "metafield:'custom.color':'Blue'")
I created a metafield definition via graphql, then added the metafield with the value "ABCD" to several products.
When I run this, I don't get any matches:
query {
products(first: 10, sortKey: TITLE, query: "metafield:'custom.mymetafield':'ABCD'") {
edges {
node {
id
title
mymetafield: metafield(namespace: "custom", key: "mymetafield") {
value
}
}
}
}
}
However, if I remove the `, query: "metafield:'custom.mymetafield':'ABCD'"` query clause, I do get back results:
{
"data": {
"products": {
"edges": [
{
"node": {
"id": "gid://shopify/Product/9018155073813",
"title": "ACME Widget #105",
"mymetafield": null
}
},
{
"node": {
"id": "gid://shopify/Product/9021689889045",
"title": "ACME Widget #142",
"mymetafield": {
"value": "ABCD"
}
}
},
{
"node": {
"id": "gid://shopify/Product/9021750739221",
"title": "ACME Widget #142",
"mymetafield": {
"value": "ABCD"
}
}
},
{
"node": {
"id": "gid://shopify/Product/9044095303957",
"title": "ACME Widget #149",
"mymetafield": {
"value": "ABCD"
}
}
},
{
"node": {
"id": "gid://shopify/Product/9017045352725",
"title": "ACME Widget #152",
"mymetafield": null
}
},
{
"node": {
"id": "gid://shopify/Product/9023227953429",
"title": "ACME Widget #157",
"mymetafield": null
}
},
{
"node": {
"id": "gid://shopify/Product/8997786943765",
"title": "ACME Widget #163",
"mymetafield": null
}
},
{
"node": {
"id": "gid://shopify/Product/9020199633173",
"title": "ACME Widget #165",
"mymetafield": null
}
},
{
"node": {
"id": "gid://shopify/Product/9021752836373",
"title": "ACME Widget #166",
"mymetafield": null
}
},
{
"node": {
"id": "gid://shopify/Product/8995263414549",
"title": "ACME Widget #17",
"mymetafield": null
}
}
]
}
}
}
Are there other prerequisite steps that I need to do?
Where should I add this query to get results?
Thankyou!
Does somone find a solution for that in 2024?
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024