@@ -1114,8 +1114,8 @@ public void analyzerWithNGramTokenizer() throws Exception {
11141114 Tree defaultAnalyzers = analyzers .addChild (FulltextIndexConstants .ANL_DEFAULT );
11151115 Tree tokenizer = defaultAnalyzers .addChild (FulltextIndexConstants .ANL_TOKENIZER );
11161116 tokenizer .setProperty (FulltextIndexConstants .ANL_NAME , "NGram" );
1117- tokenizer .setProperty ("maxGramSize " , 2 );
1118- tokenizer .setProperty ("minGramSize " , 3 );
1117+ tokenizer .setProperty ("minGramSize " , 2 );
1118+ tokenizer .setProperty ("maxGramSize " , 3 );
11191119 });
11201120
11211121 Tree content = root .getTree ("/" ).addChild ("content" );
@@ -1129,6 +1129,61 @@ public void analyzerWithNGramTokenizer() throws Exception {
11291129 assertQuery ("select * from [nt:base] where contains(*, 'ba')" , List .of ("/content/bar" ));
11301130 assertQuery ("select * from [nt:base] where contains(*, 'bar')" , List .of ("/content/bar" ));
11311131 assertQuery ("select * from [nt:base] where contains(*, 'art')" , List .of ("/content/bar" ));
1132+ // not found with Elasticsearch, but found with Lucene
1133+ // assertQuery("select * from [nt:base] where contains(*, 'foo bar')", List.of("/content/bar"));
1134+ });
1135+ }
1136+
1137+ // OAK-11568
1138+ @ Test
1139+ public void analyzerWithPatternTokenizer () throws Exception {
1140+ setup (List .of ("foo" ), idx -> {
1141+ Tree analyzers = idx .addChild (FulltextIndexConstants .ANALYZERS );
1142+ Tree defaultAnalyzers = analyzers .addChild (FulltextIndexConstants .ANL_DEFAULT );
1143+ Tree tokenizer = defaultAnalyzers .addChild (FulltextIndexConstants .ANL_TOKENIZER );
1144+ tokenizer .setProperty (FulltextIndexConstants .ANL_NAME , "pattern" );
1145+ tokenizer .setProperty ("pattern" , "[^\\ p{L}\\ d-_]" );
1146+ });
1147+
1148+ Tree content = root .getTree ("/" ).addChild ("content" );
1149+ content .addChild ("bar" ).setProperty ("foo" , "foo bar" );
1150+ root .commit ();
1151+
1152+ assertEventually (() -> {
1153+ assertQuery ("select * from [nt:base] where contains(*, 'foo')" , List .of ("/content/bar" ));
1154+ });
1155+ }
1156+
1157+ // OAK-11568
1158+ @ Test
1159+ public void analyzerWithWordDelimiterAndSynonyms () throws Exception {
1160+ setup (List .of ("foo" ), idx -> {
1161+ Tree analyzers = idx .addChild (FulltextIndexConstants .ANALYZERS );
1162+ Tree defaultAnalyzers = analyzers .addChild (FulltextIndexConstants .ANL_DEFAULT );
1163+ Tree tokenizer = defaultAnalyzers .addChild (FulltextIndexConstants .ANL_TOKENIZER );
1164+ tokenizer .setProperty (FulltextIndexConstants .ANL_NAME , "Standard" );
1165+ Tree filters = defaultAnalyzers .addChild (FulltextIndexConstants .ANL_FILTERS );
1166+ filters .setOrderableChildren (true );
1167+ filters .addChild ("LowerCase" );
1168+ // internally, this is re-ordered _after_ the synonyms filter
1169+ filters .addChild ("WordDelimiter" );
1170+ Tree synonym = filters .addChild ("Synonym" );
1171+ synonym .setProperty ("format" , "solr" );
1172+ synonym .setProperty ("ignoreCase" , true );
1173+ synonym .setProperty ("synonyms" , "synonyms.txt" );
1174+ Tree synonymTxt = synonym .addChild ("synonyms.txt" );
1175+ Tree content = synonymTxt .addChild ("jcr:content" );
1176+ content .setProperty ("jcr:data" , "find => replace\n " );
1177+ content .setProperty ("jcr:mimeType" , "text/plain" );
1178+ filters .addChild ("PorterStem" );
1179+ });
1180+
1181+ Tree content = root .getTree ("/" ).addChild ("content" );
1182+ content .addChild ("bar" ).setProperty ("foo" , "replace" );
1183+ root .commit ();
1184+
1185+ assertEventually (() -> {
1186+ assertQuery ("select * from [nt:base] where contains(*, 'find')" , List .of ("/content/bar" ));
11321187 });
11331188 }
11341189
0 commit comments