gatsby-plugin-elasticlunr-search icon indicating copy to clipboard operation
gatsby-plugin-elasticlunr-search copied to clipboard

siteSearchIndex not show - resolver problem in config

Open D19cannon opened this issue 5 years ago • 0 comments

Hey guys,

I am having this problem for a while and I have been checking every issue that is out there, including the one that are exactly the same as mine, but didn't work.

Basically, I am using the gatsby-source-wordpress plugin with elasticlunr. According to the documentation it should be rather easy. But I guess the following error is explaning that the resolver type is incorrect:

 ERROR #11321  PLUGIN

"@gatsby-contrib/gatsby-plugin-elasticlunr-search" threw an error while running the onCreateNode lifecycle:

Cannot read property 'tags' of undefined

  127 |   }
  128 |
> 129 |   if (filter && !filter(node, getNode)) {
      |                  ^
  130 |     return;
  131 |   }
  132 |

File: node_modules/@gatsby-contrib/gatsby-plugin-elasticlunr-search/gatsby-node.js:129:18

I check all the answers and most people who are using the wordpress plugin are doing exactly the same as me.


module.exports = {
  siteMetadata: {
    title: `wp-gatsby template`,
    description: `wp-gatsby template`,
    author: `D19cannon`,
  },
  plugins: [
    `gatsby-plugin-lint-queries`,
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    // Setup WPGraphQL.com to be the source
    {
      resolve: `gatsby-source-graphql`,
      options: {
        // This type will contain remote schema Query type
        typeName: `WPGraphQL`,
        // This is field under which it's accessible
        fieldName: `wpgraphql`,
        // Url to query from
        url: `http://wp.test/graphql`,
      },
    },
    {
      resolve: 'gatsby-source-wordpress',
      options: {
        baseUrl: 'wp.test/',
        // WP.com sites set to true, WP.org set to false
        hostingWPCOM: false,
        protocol: 'http',
        // Use 'Advanced Custom Fields' Wordpress plugin
        useACF: true,
        auth: {},
        // Set to true to debug endpoints on 'gatsby build'
        verboseOutput: true,
      },
    {
      resolve: `@gatsby-contrib/gatsby-plugin-elasticlunr-search`,
      options: {
        // Fields to index
        fields: [`title`],
        // How to resolve each field`s value for a supported node type
        resolvers: {
          wordpress__PAGE: {
            title: node => node.title,
          },
          wordpress__POST: {
            title: node => node.title,
          },
        },
        // Optional filter to limit indexed nodes
        filter: (node, getNode) =>
          node.frontmatter.tags !== 'exempt',
      },
    },
  ],
}

Let me know what the fields are suppose to be other than 'wordpress__POST' Thanks.

D19cannon avatar Jan 08 '20 14:01 D19cannon