File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
androidTestSupport/java/com/simperium
main/java/com/simperium/android Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -362,12 +362,17 @@ public void testFullTextSearching()
362362 note .setContent ("lorem ipsum dolor whatever" );
363363 note .addTags ("literature" );
364364
365+ note = mBucket .newObject ("ftsearch4" );
366+ note .setContent ("Бабушка means Grandmother." );
367+ note .save ();
368+
365369 assertEquals (1 , mBucket .query ().where (new Query .FullTextMatch ("town hall" )).count ());
366370
367371 assertEquals (2 , mBucket .query ().where (new Query .FullTextMatch ("two" )).count ());
368372
369373 assertEquals (1 , mBucket .query ().where (new Query .FullTextMatch ("tags:two" )).count ());
370374
375+ assertEquals (1 , mBucket .query ().where (new Query .FullTextMatch ("бабушка" )).count ());
371376 }
372377
373378 public void testFullTextSnippet ()
Original file line number Diff line number Diff line change @@ -275,6 +275,10 @@ private void setupFullText() {
275275 if (rebuild ) {
276276 mDatabase .execSQL (String .format (Locale .US , "DROP TABLE IF EXISTS `%s`" , tableName ));
277277 StringBuilder fields = new StringBuilder ();
278+ if (supportsUnicodeFullText ()) {
279+ // Add unicode case-insensitive search support
280+ fields .append ("tokenize=unicode61, " );
281+ }
278282 for (String key : keys ) {
279283 fields .append ("`" );
280284 fields .append (key );
@@ -630,15 +634,19 @@ private void compileQuery() {
630634 }
631635
632636 // See issue #150, Android < 15 can't use distinct in full text queries
633- public static boolean supportsDistinct (boolean fullTextQuery ) {
637+ static boolean supportsDistinct (boolean fullTextQuery ) {
634638
635639 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN ) {
636640 return true ;
637641 }
638642
639643 // Otherwise only use distinct if it's not a full text query
640644 return !fullTextQuery ;
645+ }
641646
647+ // Android < 21 can't use `unicode61` SQLite tokenizer
648+ static boolean supportsUnicodeFullText () {
649+ return Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ;
642650 }
643651
644652
You can’t perform that action at this time.
0 commit comments