Prismic GQL query where

Im trying to query using where via graphql. I manually setup a blog within the date range. However the home which is a document link cause the query return nothing. can someone from support team help.

{
allBlogs(where: {date_after: "2020-01-01", date_before: "2020-12-31", home: ""}) {
edges {
node {
slug
}
}
}
}

1 Like

Hi @feng.cheng, can you show us the full GraphQL query that you’re running? And can you send a link to this query in your GraphQL API so that we can take a look?

Hi Levi,

https://kaplaneducators.prismic.io &

  allBlogs(where: {date_after: "2020-01-01", date_before: "2020-12-31", home: "Xs_Y3hAAACMAKD6L"}) {
    edges {
      node {
        slug
        publisher {
          ... on Publisher {
            slug
          }
        }
      }
    }
  }
}

@feng.cheng I took a look and found that the issue here is that your date isn’t within the range you’ve set. I don’t know if it was an accident, but the date field for this document is in 2010 which is why it isn’t appearing in the results. When I changed the date range to 2010, the document appears. Here is the working query.

ah got it. thank you for the quick reply

Hi, @Levi
I'd like to implement the filtration with partial match for the Key text field "title" of EventCard by using gql query in prismic app

query GetCards($searchTerm: String!) {
    allEventcards (where: {title_fulltext: $searchTerm}) {
      edges {
        node {
          title
          description
          image
        }
      }
    }
  }

But if I pass "eve" as a searchTerm to the query, response doesn't include the cards that have title of "Event 4", "Event 3".
Only when I pass "event", it returns above cards.
I tried and researched in many ways, but I can't find the correct solution for the partial matching filtration for the text field.
Can you please give me an advance for this?

Hi, @jinwangdev531. Unfortunately, at the moment, it is not possible to search for partial words like this. I would love to see the fulltext search improved to be able to handle this as well, so I will add another tick for our feature request tracker.

Are you creating a search feature for your site? Or is this for something else? If you need a more robust search, then at the moment, we recommend using a service like Algolia to build that functionality.

Hi, @Levi
Thank you for your reply.

My name is Jin Wang and I'm a lead developer of Omnia FZ LLC in UAE.
Main tech stacks of our company are Sitecore JSS and Sitecore SXA.
We built so many project with these skills, our latest project is https://www.cop28.com/

But our company started to get interested in Prismic CMS as it also supports modern JS frameworks like NextJS, NuxtJS, etc and it seems to make it easy to build components and pages by slicemachine feature.
Now I'm building the POC app with prismic-next-js

Okay, that's fine for now.
I'll use fulltext then.

I'd need a lot of your help later :slight_smile:

Best
Jin

1 Like