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()
362
362
note .setContent ("lorem ipsum dolor whatever" );
363
363
note .addTags ("literature" );
364
364
365
+ note = mBucket .newObject ("ftsearch4" );
366
+ note .setContent ("Бабушка means Grandmother." );
367
+ note .save ();
368
+
365
369
assertEquals (1 , mBucket .query ().where (new Query .FullTextMatch ("town hall" )).count ());
366
370
367
371
assertEquals (2 , mBucket .query ().where (new Query .FullTextMatch ("two" )).count ());
368
372
369
373
assertEquals (1 , mBucket .query ().where (new Query .FullTextMatch ("tags:two" )).count ());
370
374
375
+ assertEquals (1 , mBucket .query ().where (new Query .FullTextMatch ("бабушка" )).count ());
371
376
}
372
377
373
378
public void testFullTextSnippet ()
Original file line number Diff line number Diff line change @@ -275,6 +275,10 @@ private void setupFullText() {
275
275
if (rebuild ) {
276
276
mDatabase .execSQL (String .format (Locale .US , "DROP TABLE IF EXISTS `%s`" , tableName ));
277
277
StringBuilder fields = new StringBuilder ();
278
+ if (supportsUnicodeFullText ()) {
279
+ // Add unicode case-insensitive search support
280
+ fields .append ("tokenize=unicode61, " );
281
+ }
278
282
for (String key : keys ) {
279
283
fields .append ("`" );
280
284
fields .append (key );
@@ -630,15 +634,19 @@ private void compileQuery() {
630
634
}
631
635
632
636
// 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 ) {
634
638
635
639
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN ) {
636
640
return true ;
637
641
}
638
642
639
643
// Otherwise only use distinct if it's not a full text query
640
644
return !fullTextQuery ;
645
+ }
641
646
647
+ // Android < 21 can't use `unicode61` SQLite tokenizer
648
+ static boolean supportsUnicodeFullText () {
649
+ return Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ;
642
650
}
643
651
644
652
You can’t perform that action at this time.
0 commit comments