This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 1cf5b84243e36b207f04ca939cce8b5a42f1a426 Mon Sep 17 00:00:00 2001 | |
From: tehsven <[email protected]> | |
Date: Thu, 21 Nov 2019 12:45:01 -0800 | |
Subject: [PATCH] Fix dup key error when creating second playlist | |
The passport-local-mongoose plugin creates uniqueness constraints | |
on a 'username' field for whatever model it's plugged in to. | |
It was being plugged in to all the models like Artist, Playlist, | |
and Song instead of just the User model. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Value Based Filtering | |
index = SearchIndex.new | |
index.add(0, {name: "Example name", price: 5.00}) | |
index.search("example", filter: {price: 1.00}) | |
=> returns nothing | |
index.search("example", filter: {price: 5.00}) | |
=> returns Document 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Multiple Fields per Document | |
index = SearchIndex.new | |
index.add(0, {name: "Example name", price: 5.00}) | |
index.search("example") | |
=> returns Document 0: {name: "Example name", price: 5.00} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Typo Handling | |
index = SearchIndex.new | |
index.add(0, "some more examples") | |
index.search("xamples") | |
=> returns Document 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Highlighting | |
index = SearchIndex.new | |
index.add(0, "I like movies based on cats") | |
index.add(1, "I like comics based on dogs") | |
index.add(2, "I like books based on fish") | |
index.search("cats") | |
=> returns Documents 0 with highlight ‘... based on *cats*’ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Scoring of Documents for a Query | |
index = SearchIndex.new | |
index.add(0, "some more examples") | |
index.add(1, "Examples are great for examples of examples") | |
index.search("examples") | |
=> returns Document 1 with score 1.0, Document 0 with score 0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Normalized Terms | |
index = SearchIndex.new | |
index.add(0, "this is a capitalized EXAMPLE") | |
index.add(1, "here is a lower case example") | |
index.add(2, "and one More example") | |
index.search("example") | |
=> returns Document 0, 1 and 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Full Term Searching | |
index = SearchIndex.new | |
index.add(0, "some more examples") | |
index.search("exam") | |
=> returns nothing | |
index.search("examples") | |
=> returns Document 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic Indexing and Searching | |
index = SearchIndex.new | |
index.add(0, "this is an example Document ID:0") | |
index.add(1, "here is another example Document ID:1") | |
index.add(2, "and one more Document ID:2") | |
index.search("example") | |
=> returns Documents 0 and 1 |