travis-r6s / gridsome-plugin-flexsearch

Add lightning fast search to Gridsome with FlexSearch
24 stars 7 forks source link

Is there a way to search by a nested object value? #57

Closed adamJLev closed 3 years ago

adamJLev commented 3 years ago

For example like the author.name example below. I think this used to work in an earlier version... did it get removed? thank you!

      options: {
        searchFields: ['title', 'description', 'author.name'],
        collections: [
          {
            typeName: 'BlogPost',
            indexName: 'BlogPost',
            fields: ['title', 'description'],
          },
        ],
      },
travis-r6s commented 3 years ago

@adamJLev I'm not sure that there is at the moment, I haven't yet added support for it. I'll look into that though. I don't think that this plugin has ever supported searching in nested fields? It does support nested fields for the search result though.

yanuha commented 3 years ago

I have a similar question. Search doesn't work for a nested object value content.text :-(

Search for 'title' works but not for 'content.text'

I'm using graphcms to store data.

gridsome settings:

{
      use: 'gridsome-plugin-flexsearch',
      options: {
        searchFields: ['title', 'content'],
        collections: [
          {
            indexName: 'Article',
            query: `{ gcms { blogArticles { title, id, slug, articleImage { url }, content { text } } } }`,
            path: 'gcms.blogArticles',
          },
        ],
      },
    },

The official documentation has something about this - https://github.com/nextapps-de/flexsearch#complex-objects

travis-r6s commented 3 years ago

@adamJLev Does the above PR help with your usecase?

alexander-heimbuch commented 3 years ago

I've added the helper with PR #66 to the GraphQL source.