Code Monkey home page Code Monkey logo

Comments (12)

dw235 avatar dw235 commented on June 18, 2024 4

@dylanpinn Very helpful!

In my case, when using the gatsby-source-drupal plugin, my working gatsby-config.js looks like this:

   {
      resolve: `@gatsby-contrib/gatsby-plugin-elasticlunr-search`,
      options: {
        fields: [`title`],
        resolvers: {
          node__topic: {
            title: node => node.title,
            path: node => node.path.alias,
          },
        },
      },
    },

The resolver for content is node__content_type_name. In my case I have a Drupal content type called topic.

Thanks again!

from gatsby-plugin-elasticlunr-search.

dylanpinn avatar dylanpinn commented on June 18, 2024 3

@seanngpack Here is our config. It works though I am still not 100% finished with it yet.

    {
      resolve: `@gatsby-contrib/gatsby-plugin-elasticlunr-search`,
      options: {
        fields: ['title', 'content'],
        resolvers: {
          wordpress__POST: {
            title: node => node.title,
            link: node => node.link,
            filter: () => 'page-content',
          },
          wordpress__PAGE: {
            title: node => node.title,
            content: node => {
              return node;
            },
            link: node => node.link,
            filter: () => 'page-content',
          },
          wordpress__wp_document: {
            title: node => node.title,
            link: node => node.link,
            filter: () => 'document',
          },
        },
      },
    },

from gatsby-plugin-elasticlunr-search.

dylanpinn avatar dylanpinn commented on June 18, 2024 2

For those that come here searching for a solution to this. It appears that a fork has been created for V2 https://github.com/gatsby-contrib/gatsby-plugin-elasticlunr-search.

This fixes the issue for me.

from gatsby-plugin-elasticlunr-search.

dylanpinn avatar dylanpinn commented on June 18, 2024 1

@dw235 I can't remember exactly but it was probably logging out all of the results from using the onCreateNode API (https://www.gatsbyjs.org/docs/node-apis/#onCreateNode) in my gatsby-node.js.

Easiest way I found to do this was to output the build results to a file which was easier to search through: gatsby build > output.log etc.

from gatsby-plugin-elasticlunr-search.

seanngpack avatar seanngpack commented on June 18, 2024

I'm still having the same issue @devinswett, the siteSearchIndex doesn't seem to be created. Maybe it's an issue with how the gatsby-config is set up?

from gatsby-plugin-elasticlunr-search.

seanngpack avatar seanngpack commented on June 18, 2024

@dylanpinn Hey, can you post your gatsby-config? The nodes are not being generated for me and I'm using the forked version and Gatsby V2.

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: {
          // For any node of type MarkdownRemark, list how to resolve the fields` values
          wordpressPost: {
            title: node => node.title,
            // path: node => node.slug,
            // tags: node => node.tags,
            // keywords: node => node.acf.keywords,
          },
        },
      },
    },

from gatsby-plugin-elasticlunr-search.

seanngpack avatar seanngpack commented on June 18, 2024

@dylanpinn OHHHHH, I was using the wrong resolvers. Thank you!

from gatsby-plugin-elasticlunr-search.

ashokballolli avatar ashokballolli commented on June 18, 2024

Hi @dylanpinn @seanngpack i am facing the similar issue Actually i am dynamically creating the pages by reading the content from excel sheet using gatsby-source-filesystem and gatsby-transformer-excel and i want to use @gatsby-contrib/gatsby-plugin-elasticlunr-search for search on the nodes created from the excel data. But i am getting the error message in graphiql "Cannot query field "siteSearchIndex" on type "RootQueryType".". Need your help in understanding what i am doing wrong here. Thanks in advance.

Details:

Plugins:

    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/src/pages`,
        name: "pages",
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `data`,
        path: `${__dirname}/src/data/`,
        ignore: [`**/\.*`], // ignore files starting with a dot
        },
     },
     `gatsby-transformer-excel`,
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-responsive-iframe`,
            options: {
              wrapperStyle: `margin-bottom: 1.05rem`,
            },
          },
          `gatsby-remark-prismjs`,
          `gatsby-remark-copy-linked-files`,
          `gatsby-remark-autolink-headers`,
          `gatsby-remark-smartypants`,
        ],
      },
    },
    `gatsby-plugin-stylus`,
    `gatsby-plugin-react-helmet`,
    {
        resolve: `@gatsby-contrib/gatsby-plugin-elasticlunr-search`,
        options: {
            // Fields to index
            fields: [
                'Summary',
                'Description',
            ],
            // How to resolve each field's value for a supported node type
            resolvers: {
                // For any node of type MarkdownRemark, list how to resolve the fields' values
                JobsdataXlsmGovtJobs: {
                    Summary: node => node.Summary,
                    Description: node => node.Description,
                },
            },
        },
    },
  ] ```

Thanks

from gatsby-plugin-elasticlunr-search.

dylanpinn avatar dylanpinn commented on June 18, 2024

@ashokballolli Sorry, I haven't seen that error before. Maybe try posting on Stack Overflow or creating a new issue.

from gatsby-plugin-elasticlunr-search.

dw235 avatar dw235 commented on June 18, 2024

@dylanpinn How did you determine the resolvers (i.e. wordpress__POST, wordpress__PAGE, wordpress__wp_document)?

I'm trying to implement the plugin using Drupal source data. I keep coming up with the same error @seanngpack was experiencing, "The @gatsby-contrib/gatsby-plugin-elasticlunr-search plugin has generated no Gatsby nodes." I'm thinking my issue is due to not knowing the correct resolvers in my case.

Thanks.

from gatsby-plugin-elasticlunr-search.

skrbnv avatar skrbnv commented on June 18, 2024

Just in case, if you are using prismic, this plugin is looking not for node.type but for node.internal.type which is different (for example "PrismicBlogPage" instead of "BlogPage")

from gatsby-plugin-elasticlunr-search.

sean-gilmore avatar sean-gilmore commented on June 18, 2024

For anyone using the gatsby-source-craft plugin, you can use the GraphQLI explorer to query for the expected Entry type and include the __typename field in the query to return the correct type for your resolver.

from gatsby-plugin-elasticlunr-search.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.