Schema for case insensitive reads


(Avinash Jain) #1

City Nodes :- Pune, Mumbai, Kolkata, Chennai, Puri, Puneri

case insensitive Reads :-
Partial search read >> contains 2 or more characters anywhere
eg:- Pu
Expected results :- Pune, Puri, Puneri
eg:- ai
Expected results :- Mumbai, Chennai
Exact read >> equals name of the node
eg:- pune
Expected result :- Pune

What schema should i use to define these nodes and how to read both cases?


(Daniel Mai) #2

Case-insensitive, partial word, and (case-insensitive) exact matches can be done with the regular expression trigram string index. See the “Indexing” section of the docs for more info: https://docs.dgraph.io/query-language/#indexing


(Avijain7143) #3

But I want to get the exact matching node. Regexp function requires expressions. And i have full node name.


(Daniel Mai) #4

The example you gave is case-insensitive exact match. There’s the exact string index, but that doesn’t satisfy your case-insensitive requirement. You could store your values in a normalized form like all lowercase. If you did that, then you could use exact.