@ -23,7 +23,7 @@ describe("Search", () => {
) ;
const searchContext = new SearchContext ( ) ;
const searchResults = searchService . find Note sWithQuery( 'europe austria' , searchContext ) ;
const searchResults = searchService . find Result sWithQuery( 'europe austria' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Austria" ) ) . toBeTruthy ( ) ;
@ -40,12 +40,12 @@ describe("Search", () => {
. label ( 'inhabitants' , '1888776' ) ) ;
const searchContext = new SearchContext ( ) ;
let searchResults = searchService . find Note sWithQuery( 'capital' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( 'capital' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Austria" ) ) . toBeTruthy ( ) ;
searchResults = searchService . find Note sWithQuery( 'inhabitants' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( 'inhabitants' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Vienna" ) ) . toBeTruthy ( ) ;
@ -57,17 +57,17 @@ describe("Search", () => {
. child ( note ( "Hello World.java" , { type : 'code' , mime : 'text/x-java' } ) ) ;
const searchContext = new SearchContext ( ) ;
let searchResults = searchService . find Note sWithQuery( 'book' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( 'book' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Effective Java" ) ) . toBeTruthy ( ) ;
searchResults = searchService . find Note sWithQuery( 'text' , searchContext ) ; // should match mime
searchResults = searchService . find Result sWithQuery( 'text' , searchContext ) ; // should match mime
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Hello World.java" ) ) . toBeTruthy ( ) ;
searchResults = searchService . find Note sWithQuery( 'java' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( 'java' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 2 ) ;
} ) ;
@ -79,7 +79,7 @@ describe("Search", () => {
) ;
const searchContext = new SearchContext ( ) ;
const searchResults = searchService . find Note sWithQuery( 'europe' , searchContext ) ;
const searchResults = searchService . find Result sWithQuery( 'europe' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Europe" ) ) . toBeTruthy ( ) ;
@ -94,7 +94,7 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
const searchResults = searchService . find Note sWithQuery( 'Vienna' , searchContext ) ;
const searchResults = searchService . find Result sWithQuery( 'Vienna' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Austria" ) ) . toBeTruthy ( ) ;
} ) ;
@ -110,16 +110,16 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
let searchResults = searchService . find Note sWithQuery( '#capital=Vienna' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( '#capital=Vienna' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Austria" ) ) . toBeTruthy ( ) ;
// case sensitivity:
searchResults = searchService . find Note sWithQuery( '#CAPITAL=VIENNA' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '#CAPITAL=VIENNA' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Austria" ) ) . toBeTruthy ( ) ;
searchResults = searchService . find Note sWithQuery( '#caPItal=vienNa' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '#caPItal=vienNa' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Austria" ) ) . toBeTruthy ( ) ;
} ) ;
@ -135,7 +135,7 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
let searchResults = searchService . find Note sWithQuery( '# note.labels.capital=Prague' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( '# note.labels.capital=Prague' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Czech Republic" ) ) . toBeTruthy ( ) ;
} ) ;
@ -152,7 +152,7 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
const searchResults = searchService . find Note sWithQuery( '#country #population >= 10000000' , searchContext ) ;
const searchResults = searchService . find Result sWithQuery( '#country #population >= 10000000' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Czech Republic" ) ) . toBeTruthy ( ) ;
} ) ;
@ -173,11 +173,11 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
let searchResults = searchService . find Note sWithQuery( '#established <= "1955-01-01"' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( '#established <= "1955-01-01"' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Hungary" ) ) . toBeTruthy ( ) ;
searchResults = searchService . find Note sWithQuery( '#established > "1955-01-01"' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '#established > "1955-01-01"' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 2 ) ;
expect ( findNoteByTitle ( searchResults , "Austria" ) ) . toBeTruthy ( ) ;
expect ( findNoteByTitle ( searchResults , "Czech Republic" ) ) . toBeTruthy ( ) ;
@ -197,7 +197,7 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
function test ( query , expectedResultCount ) {
const searchResults = searchService . find Note sWithQuery( query , searchContext ) ;
const searchResults = searchService . find Result sWithQuery( query , searchContext ) ;
expect ( searchResults . length ) . toEqual ( expectedResultCount ) ;
if ( expectedResultCount === 1 ) {
@ -251,7 +251,7 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
const searchResults = searchService . find Note sWithQuery( '#languageFamily = slavic OR #languageFamily = germanic' , searchContext ) ;
const searchResults = searchService . find Result sWithQuery( '#languageFamily = slavic OR #languageFamily = germanic' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 2 ) ;
expect ( findNoteByTitle ( searchResults , "Czech Republic" ) ) . toBeTruthy ( ) ;
expect ( findNoteByTitle ( searchResults , "Austria" ) ) . toBeTruthy ( ) ;
@ -268,18 +268,18 @@ describe("Search", () => {
let searchContext = new SearchContext ( { fuzzyAttributeSearch : false } ) ;
let searchResults = searchService . find Note sWithQuery( '#language' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( '#language' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 0 ) ;
searchResults = searchService . find Note sWithQuery( '#languageFamily=ger' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '#languageFamily=ger' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 0 ) ;
searchContext = new SearchContext ( { fuzzyAttributeSearch : true } ) ;
searchResults = searchService . find Note sWithQuery( '#language' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '#language' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 2 ) ;
searchResults = searchService . find Note sWithQuery( '#languageFamily=ger' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '#languageFamily=ger' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Austria" ) ) . toBeTruthy ( ) ;
} ) ;
@ -292,7 +292,7 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
const searchResults = searchService . find Note sWithQuery( '# note.title =* czech' , searchContext ) ;
const searchResults = searchService . find Result sWithQuery( '# note.title =* czech' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Czech Republic" ) ) . toBeTruthy ( ) ;
} ) ;
@ -309,16 +309,16 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
let searchResults = searchService . find Note sWithQuery( '# note.parents.title = Europe' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( '# note.parents.title = Europe' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 2 ) ;
expect ( findNoteByTitle ( searchResults , "Austria" ) ) . toBeTruthy ( ) ;
expect ( findNoteByTitle ( searchResults , "Czech Republic" ) ) . toBeTruthy ( ) ;
searchResults = searchService . find Note sWithQuery( '# note.parents.title = Asia' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '# note.parents.title = Asia' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Taiwan" ) ) . toBeTruthy ( ) ;
searchResults = searchService . find Note sWithQuery( '# note.parents.parents.title = Europe' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '# note.parents.parents.title = Europe' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Prague" ) ) . toBeTruthy ( ) ;
} ) ;
@ -337,11 +337,11 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
let searchResults = searchService . find Note sWithQuery( '#city AND note.ancestors.title = Europe' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( '#city AND note.ancestors.title = Europe' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Prague" ) ) . toBeTruthy ( ) ;
searchResults = searchService . find Note sWithQuery( '#city AND note.ancestors.title = Asia' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '#city AND note.ancestors.title = Asia' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Taipei" ) ) . toBeTruthy ( ) ;
} ) ;
@ -358,16 +358,16 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
let searchResults = searchService . find Note sWithQuery( '# note.children.title =* Aust' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( '# note.children.title =* Aust' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 2 ) ;
expect ( findNoteByTitle ( searchResults , "Europe" ) ) . toBeTruthy ( ) ;
expect ( findNoteByTitle ( searchResults , "Oceania" ) ) . toBeTruthy ( ) ;
searchResults = searchService . find Note sWithQuery( '# note.children.title =* Aust AND note.children.title *= republic' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '# note.children.title =* Aust AND note.children.title *= republic' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Europe" ) ) . toBeTruthy ( ) ;
searchResults = searchService . find Note sWithQuery( '# note.children.children.title = Prague' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '# note.children.children.title = Prague' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Europe" ) ) . toBeTruthy ( ) ;
} ) ;
@ -388,11 +388,11 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
let searchResults = searchService . find Note sWithQuery( '# ~neighbor.title = Austria' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( '# ~neighbor.title = Austria' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Czech Republic" ) ) . toBeTruthy ( ) ;
searchResults = searchService . find Note sWithQuery( '# ~neighbor.title = Portugal' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '# ~neighbor.title = Portugal' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Spain" ) ) . toBeTruthy ( ) ;
} ) ;
@ -413,7 +413,7 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
const searchResults = searchService . find Note sWithQuery( '# note.relations.neighbor.title = Austria' , searchContext ) ;
const searchResults = searchService . find Result sWithQuery( '# note.relations.neighbor.title = Austria' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Czech Republic" ) ) . toBeTruthy ( ) ;
} ) ;
@ -439,11 +439,11 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
let searchResults = searchService . find Note sWithQuery( '# note.relations.neighbor.relations.neighbor.title = Italy' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( '# note.relations.neighbor.relations.neighbor.title = Italy' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( findNoteByTitle ( searchResults , "Czech Republic" ) ) . toBeTruthy ( ) ;
searchResults = searchService . find Note sWithQuery( '# note.relations.neighbor.relations.neighbor.title = Ukraine' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '# note.relations.neighbor.relations.neighbor.title = Ukraine' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 2 ) ;
expect ( findNoteByTitle ( searchResults , "Czech Republic" ) ) . toBeTruthy ( ) ;
expect ( findNoteByTitle ( searchResults , "Austria" ) ) . toBeTruthy ( ) ;
@ -477,7 +477,7 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
function test ( propertyName , value , expectedResultCount ) {
const searchResults = searchService . find Note sWithQuery( ` # note. ${ propertyName } = ${ value } ` , searchContext ) ;
const searchResults = searchService . find Result sWithQuery( ` # note. ${ propertyName } = ${ value } ` , searchContext ) ;
expect ( searchResults . length ) . toEqual ( expectedResultCount ) ;
}
@ -536,36 +536,36 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
let searchResults = searchService . find Note sWithQuery( '# note.parents.title = Europe orderBy note.title' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( '# note.parents.title = Europe orderBy note.title' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 4 ) ;
expect ( becca . notes [ searchResults [ 0 ] . noteId ] . title ) . toEqual ( "Austria" ) ;
expect ( becca . notes [ searchResults [ 1 ] . noteId ] . title ) . toEqual ( "Italy" ) ;
expect ( becca . notes [ searchResults [ 2 ] . noteId ] . title ) . toEqual ( "Slovakia" ) ;
expect ( becca . notes [ searchResults [ 3 ] . noteId ] . title ) . toEqual ( "Ukraine" ) ;
searchResults = searchService . find Note sWithQuery( '# note.parents.title = Europe orderBy note.labels.capital' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '# note.parents.title = Europe orderBy note.labels.capital' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 4 ) ;
expect ( becca . notes [ searchResults [ 0 ] . noteId ] . title ) . toEqual ( "Slovakia" ) ;
expect ( becca . notes [ searchResults [ 1 ] . noteId ] . title ) . toEqual ( "Ukraine" ) ;
expect ( becca . notes [ searchResults [ 2 ] . noteId ] . title ) . toEqual ( "Italy" ) ;
expect ( becca . notes [ searchResults [ 3 ] . noteId ] . title ) . toEqual ( "Austria" ) ;
searchResults = searchService . find Note sWithQuery( '# note.parents.title = Europe orderBy note.labels.capital DESC' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '# note.parents.title = Europe orderBy note.labels.capital DESC' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 4 ) ;
expect ( becca . notes [ searchResults [ 0 ] . noteId ] . title ) . toEqual ( "Austria" ) ;
expect ( becca . notes [ searchResults [ 1 ] . noteId ] . title ) . toEqual ( "Italy" ) ;
expect ( becca . notes [ searchResults [ 2 ] . noteId ] . title ) . toEqual ( "Ukraine" ) ;
expect ( becca . notes [ searchResults [ 3 ] . noteId ] . title ) . toEqual ( "Slovakia" ) ;
searchResults = searchService . find Note sWithQuery( '# note.parents.title = Europe orderBy note.labels.capital DESC limit 2' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '# note.parents.title = Europe orderBy note.labels.capital DESC limit 2' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 2 ) ;
expect ( becca . notes [ searchResults [ 0 ] . noteId ] . title ) . toEqual ( "Austria" ) ;
expect ( becca . notes [ searchResults [ 1 ] . noteId ] . title ) . toEqual ( "Italy" ) ;
searchResults = searchService . find Note sWithQuery( '# note.parents.title = Europe orderBy #capital DESC limit 1' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '# note.parents.title = Europe orderBy #capital DESC limit 1' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
searchResults = searchService . find Note sWithQuery( '# note.parents.title = Europe orderBy #capital DESC limit 1000' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '# note.parents.title = Europe orderBy #capital DESC limit 1000' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 4 ) ;
} ) ;
@ -580,11 +580,11 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
let searchResults = searchService . find Note sWithQuery( '# not(#capital) and note.noteId != root' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( '# not(#capital) and note.noteId != root' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( becca . notes [ searchResults [ 0 ] . noteId ] . title ) . toEqual ( "Europe" ) ;
searchResults = searchService . find Note sWithQuery( '#!capital and note.noteId != root' , searchContext ) ;
searchResults = searchService . find Result sWithQuery( '#!capital and note.noteId != root' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( becca . notes [ searchResults [ 0 ] . noteId ] . title ) . toEqual ( "Europe" ) ;
} ) ;
@ -600,7 +600,7 @@ describe("Search", () => {
const searchContext = new SearchContext ( ) ;
let searchResults = searchService . find Note sWithQuery( '# note.text *=* vaki and note.noteId != root' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( '# note.text *=* vaki and note.noteId != root' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( becca . notes [ searchResults [ 0 ] . noteId ] . title ) . toEqual ( "Slovakia" ) ;
} ) ;
@ -617,7 +617,7 @@ describe("Search", () => {
const searchContext = new SearchContext ( { excludeArchived : true } ) ;
let searchResults = searchService . find Note sWithQuery( 'reddit' , searchContext ) ;
let searchResults = searchService . find Result sWithQuery( 'reddit' , searchContext ) ;
expect ( searchResults . length ) . toEqual ( 1 ) ;
expect ( becca . notes [ searchResults [ 0 ] . noteId ] . title ) . toEqual ( "Reddit is bad" ) ;
} ) ;
@ -640,7 +640,7 @@ describe("Search", () => {
//
// const searchContext = new SearchContext();
//
// const searchResults = searchService.find Note sWithQuery('#capital = #largestCity', searchContext);
// const searchResults = searchService.find Result sWithQuery('#capital = #largestCity', searchContext);
// expect(searchResults.length).toEqual(2);
// expect(findNoteByTitle(searchResults, "Czech Republic")).toBeTruthy();
// expect(findNoteByTitle(searchResults, "Austria")).toBeTruthy();