When I try to query using Prismic full text predicate it keeps giving an error about unexpected fields
P粉739886290
P粉739886290 2024-03-31 21:14:37
0
1
547

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粉739886290
P粉739886290

reply all(1)
P粉404539732

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 :)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template