searchField as an array
lindsaykwardell opened this issue · 2 comments
Hello, I'm having some trouble with setting up search fields. Here is my markdown file frontmatter:
---
path: "/new-website"
date: 2019-08-04
title: "New Website"
author: "Lindsay Wardell"
tags:
- Web Development
- Personal
---
I set up my configuration as follows:
{
use: 'gridsome-plugin-flexsearch',
options: {
collections: [
{
typeName: 'Post',
indexName: 'Post',
fields: ['title', 'content', 'tags', 'author', 'date']
}
],
searchFields: ['title', 'tags']
}
}
The field 'tags' is an array in the Markdown files. When I search for a tag, it does not appear to filter by that tag, only by the title. Does this plugin support arrays as a searchField?
@lindsaykwardell I have released an update that allows searchFields
to be an object, so you should be able to do something like nextapps-de/flexsearch#36 (comment)
searchFields: {
tags: {
encode: "extra",
tokenize: "full"
}
}
Not sure if that will work for you - hopefully the new FlexSearch v0.7.0 release will handle searching arrays better.
Have also fixed an issue where the client-side FlexSearch instance wasn't using the configured search preset, so you should now be able to to search arrays correctly.