Skip to content

TehShrike/noddity-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

noddity-search

Making it easy for you to add search functionality to your Noddity blag or server.

Part of the Noddity ecosystem, lulz

Usage

var fields = {
	customParameterInMyMetadata: 10
}

var searcher = require('noddity-search')
var search = searcher(noddityButler, fields)

search('butts', function(err, posts) {
	posts.forEach(function(post) {
		console.log('found post', post.title)
	})
})

Construction

searcher(butler, [fields])

butler is a noddity-butler

fields is an optional key:boost mapping. Add any custom metadata properties you want to use, and tweak their score accordingly.

Currently, metadata.title and content are indexed with scores of 10 and 1 respectively. If you want to pass in custom indexing/boosting directions, they might look something like this:

{
	title: 20,
	tags: 50
}

The construction method returns a function to be used for searching. Explained here:

Searching

search('this text was typed into an autocomplete bae', function(err, posts) {
	console.log(posts)
})

Whatever text your funky users typed, pass it to the search function and it will be thrown at the side of the lunr index, with the resulting posts returned to you in an error-first callback.

License

WTFPL

About

A lunr-powered search function for Noddity sites

Resources

Stars

Watchers

Forks

Packages

No packages published