Home  >  Q&A  >  body text

When I try to query using Prismic full text predicate it keeps giving an error about unexpected fields

I'm trying to query Prismic predicate.fulltext using Vuejs This is my first time using predicates, but the documentation on what is required for full-text predicates seems confusing. Here is my code.

async searchByQuery(query) {
    const fullTextResult = await this.$prismic.client.get({
      predicates: this.$prismic.predicate.not("articles.article_title", query),
    });
    console.log(fullTextResult);
  },

Where articles is my custom type, article_title is a field in my custom type. This is what I understand from the documentation on how to do this, but then I get an unexpected error

I'd like to clarify why this doesn't work and what the documentation really means. BTW, I'm using Vue3, which means I'm using the newer prismicio/client

P粉739886290P粉739886290219 days ago475

reply all(1)I'll reply

  • P粉404539732

    P粉4045397322024-04-01 15:02:12

    You're so close!

    With Vue 3, you would see something similar:

    export default {
      methods: {
        async searchByQuery(query) {
          const fullTextResult = await this.$prismic.client.get({
            predicates:
              this.$prismic.predicate.fulltext(
                "my.articles.article_title",
                query
              )
          });
    
          console.log(fullTextResult);
        }
      }
    };
    

    Basically you need to prefix my. to indicate that it is a field of one of your document types and change the predicate you use for precidate.fulltext instead of predicate.not (assuming you want to run a full text search) Please tell me if this helps :)

    reply
    0
  • Cancelreply