2017-02-08 9 views
3

Mein Team beschließt Realm als Datenbanken zu verwenden, aber ich habe eine Frage zu stellen, Unterstützt Realm Fuzzy-Abfrage wie SQLite Keyword verwenden "wie" oder "%". Manchmal müssen wir verwenden Fuzzy-AbfrageUnterstützt Realm Fuzzy-Abfrage auf Android

+1

Wie Abfrage unterstützt wird seit 2.3.0 siehe https://github.com/realm/realm-java/issues/3752 – EpicPandaForce

Antwort

4

LIKE query is supported since 2.3.0.

public RealmQuery<E> like(String fieldName, 
          String value, 
          Case casing) 

Condition that the value of field matches with the specified substring, with wildcards: 
    '*' matches [0, n] unicode chars 
    '?' matches a single unicode char. 

Parameters: 
    fieldName - the field to compare. 
    value - the wildcard string. 
    casing - how to handle casing. Setting this to Case.INSENSITIVE only works for Latin-1 characters. 

Beispiele:

realm.where(Person.class).like("name", "*").findAll(); 
realm.where(Person.class).like("name", "?ohn*", Case.SENSITIVE).findAll();