I am looking to do a blog title search, with an exact match
query ($query: String!){
articles(first: 10, query: $query) {
edges {
node {
id
handle
title
tags
}
}
}
}
Using
{"query": "'this being exact'"}
But that does look to work, just brings lots of non similar results. I can’t seem to target the title. I tried this
{"query": "query=title:this being exact"}
But got
"warnings": [
{
"field": "query=title",
"message": "Invalid search field for this query."
}
]
Any ideas?
Thanks
Grant
Hi Grant,
If you restructure your query like this, will it work?
query {
articles(first: 10, query: "\"this being exact\"") {
edges {
node {
id
handle
title
tags
}
}
}
}
I had tried that but I think that search all of the content and not the title. The documentation (articles - GraphQL Admin) implies that title should work in a query, but it does look to.
So, I messed around a bit, and this looks better
query ($query: String!, $sortKey: ArticleSortKeys!, $reverse: Boolean!, $first: Int){
articles(first: $first, query: $query, sortKey: $sortKey, reverse: $reverse) {
edges {
node {
id
handle
title
tags
}
}
}
}
and
{
"query":"\"this being exact\"",
"sortKey":"RELEVANCE",
"reverse":true,
"first":10
}
It could be that it was returning the results but it was one of many, sorting by relevance allowed me to see the one I was looking for
I will continue to test this, but for the one I was testing against it worked
1 Like
Hey Grant,
Thanks for posting up this query - glad it’s working as expected.