How to use createIndex in Javascript?
See original GitHub issueHi, I’m trying to implement the index search for Fuse, but for some reason it’s not working. My error is
fuse_js__WEBPACK_IMPORTED_MODULE_27___default.a.createIndex is not a function
import Fuse from 'fuse.js'
const sampleRecipes = [
{
id: 1,
name: 'Plain Chicken',
servings: 3,
cookTime: '1:45',
instructions: "1. Put salt on chicken\n2. Put chicken in oven\n3. Eat chicken",
ingredients: [
{
id: 1,
name: 'Chicken',
amount: '2 Pounds'
},
{
id: 2,
name: 'Salt',
amount: '1 Tbs'
}
],
authors: [
{
id: 1,
name: "nun",
email: "nunny@gmail.com"
},
{
id: 2,
name: "matt",
email:'mwong@gmail.com'
}
]
},
{
id: 2,
name: 'Plain Pork',
servings: 5,
cookTime: '0:45',
instructions: "1. Put paprika on pork\n2. Put pork in oven\n3. Eat pork",
ingredients: [
{
id: 1,
name: 'Pork',
amount: '3 Pounds'
},
{
id: 2,
name: 'Paprika',
amount: '2 Tbs'
}
],
authors: [
{
id: 1,
name: "pun",
email: "hat@gmail.com"
},
{
id: 2,
name: "mun",
email:'geo@gmail.com'
}
]
}
]
const fuseListforIndex = [...sampleRecipes];
const index = Fuse.createIndex(
['name',],
fuseListforIndex
)
const options = {
keys: ['name']
}
const myFuse = new Fuse(fuseListforIndex, options, index)
const result = myFuse.search('Pork')
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
IDBObjectStore.createIndex() - Web APIs | MDN
The createIndex() method of the IDBObjectStore interface creates and returns a new IDBIndex object in the connected database.
Read more >Indexes — Node.js - MongoDB
The following example uses the createIndex() method to create a compound index on the type and genre fields in the movies collection in...
Read more >mongodb.Collection.createIndex JavaScript and Node.js code ...
How to use. createIndex. function. in. Collection. Best JavaScript code snippets using mongodb.Collection.
Read more >create-index - npm
create-index program will look into the target directory. If there is no ./index.js , it will create a new file, e.g. ... Created...
Read more >node.js - MongoDB ensurIndex and createIndex using nodeJS?
If you want to add an index to some field, just add index: true to its definition. So you can do the following:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
in case it helps anyone, if you want to pre-build the index this worked for me:
disclaimer: I’m not sure if this is officially supported or even the right way to do it!
This is right way to do it, and officially supported.