noddity-search
A lunr-powered search function for Noddity sites
Last updated 5 years ago by tehshrike .
WTFPL · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install noddity-search 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.1                                ...           latest (5 years ago)

2 Versions

  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |