"select * from prefixes where '+39123412341' like prefix || '%" in GraphQL

Dear Friends

I want to port old SQL telephone numer database to dgraph. The database instead of full 11-digit tel. numbers contains prefixes ( e.g.) +38, +391, +3912. Then I search for all records which start the given full telephone numer:

select * from prefixes where '+39123412341' like prefix || '%';

Assuming that the table contains the following prefixes ( +38, +391, +3912, +392) the query returns ( +391, +3912)

Friends I wonder if such query can be effectively written and executed in GraphQL.
Can anyone of you point me in the right direction.

Regards
Jacek

I don’t get it completely. But looks like you would have to use a regex pattern to do so.

e.g:

query {
    queryPost(filter: { tags: { regexp: "/.*aph.*/" } } ) { ... }
}

No Dgraph query function can be aware of such a pattern β€˜+39123412341’.

We currently do not have very many string functions supported, but with String Functions in DQL, we will be supporting them soon.

Once we have substring, then you can do something like

q(func: eq(prefixes, substring(+391234, 1))){...}
1 Like