lunr.js
A bit like Solr, but much smaller and not as bright
lunr.js - A bit like Solr, but much smaller and not as bright
In lunr.js, you can add a unique reference using the .ref()
method but I can't find any method to add extra data/info about that particular record. Is it not possible or am I missing something really obvious.
I even tried assigning an object to ref but it saves it as a string.
EDIT
For now I am saving all the contents as a JSON string in .ref()
, which works but is really ugly to use.
Source: (StackOverflow)
I'm trying to implement search on my Jekyll site using Lunar JS with this plugin. https://github.com/slashdotdash/jekyll-lunr-js-search
I'm following the instructions in the readme but to a beginner they are not so clear.
I've followed everything up to step 5, ie added all the scripts to my template, and created a search box and container for my search results on the page I want to have search functionality.
However, step 6 says: "Create a Mustache template to display the search results." Where do I need to put this code? In a separate file? Or on the same page as I have my search box?
And step 7 requires me to add:
`indexUrl: '/search.json', // URL of the `search.json` index data for your site`
Can somebody explain what this means? I know lunrjs is supposed to create a json file with all my blog data, but I can't find this json file anywhere. Am I doing something wrong?
Source: (StackOverflow)
Although the default filter provides adequate results, I'm attempting to filter the contents of an ng-repeat
using the results of a lunr.js search.
.filter('lunrFilter', function() {
return function(items, query) {
var filteredSearchResults = [];
$scope.searchIndex(query).forEach(function(item) {
filteredSearchResults.push(item);
});
return filteredSearchResults;
}
})
$scope.searchIndex = function(q) {
$scope.searchResults = $scope.indexedText.search(q)
.map(function (result) {
return $scope.items.filter(function (q) {
return q.id === parseInt(result.ref, 10) // Adds id field to object
})[0];
});
console.log($scope.searchResults);
return $scope.searchResults;
};
My searchIndex()
function works adequately, but I'm stumped when it comes to adding the results of that array into filteredSearchResults
, or using .filter()
on it.
I can't get my head to figure it out - particularly as calling $scope.searchIndex
within my filter returns $scope is not defined
.
Source: (StackOverflow)
I am currently using a modified version of the jekyll-lunr-js-search Plugin.
What I'd like to do is include processes excerpts in my search results but using something like :
site = context.registers[:site]
converter = site.getConverterImpl(::Jekyll::Converters::Markdown)
output = converter.convert(super(context))
results in content that has still has jekyll tags in it (i.e. {% include JB/setup %} or {% highlight yaml % block)
Is there a way to call the site render process on a string?
Source: (StackOverflow)
I'm using lunr to perform a search and I currently am highlighting the search from the value of the search text area, but lunr uses a stemmer and returns results that don't specifically match the full search term. is there a way to access the stem of the search term that lunr ends up searching on?
// query our lunr index
searchResults = _.map(index.search($('#searchInput').val()), function (res) {
var uid = res.ref;
return mediaList[uid];
});
Source: (StackOverflow)
I am new to backgrid.js and I am using filter as an extension function for my web app. I am quite confused about LunrFilter
. As the code defines in this page, it has the parameter { field : 10 }
. May I know what and how does field name and boost value affect the filtration of collection?
Also, is it possible for Backgrid.filter to filter collections by precedence?
For example, I have the following data:
Record #1 - fname : Adam; lname : Smith
Record #2 - fname : Luke; lname : Adam
Record #3 - fname : John; lname : Adam
I would like to take precedence of lname
over fname
on filtering.
If I key in "Adam" on search bar - table must display Records #2 and #3 first, and #1 last.
Source: (StackOverflow)