Ask a Question

Language Support

Note A @lang directive must be specified in the schema to query or mutate predicates with language tags.

Dgraph supports UTF-8 strings.

In a query, for a string valued edge edge, the syntax

[email protected]:...:langN

specifies the preference order for returned languages, with the following rules.

  • At most one result will be returned (except in the case where the language list is set to *).
  • The preference list is considered left to right: if a value in given language is not found, the next language from the list is considered.
  • If there are no values in any of the specified languages, no value is returned.
  • A final . means that a value without a specified language is returned or if there is no value without language, a value in ‘‘some’’ language is returned.
  • Setting the language list value to * will return all the values for that predicate along with their language. Values without a language tag are also returned.

For example:

  • name => Look for an untagged string; return nothing if no untagged value exits.
  • [email protected] => Look for an untagged string, then any language.
  • [email protected] => Look for en tagged string; return nothing if no en tagged string exists.
  • [email protected]:. => Look for en, then untagged, then any language.
  • [email protected]:pl => Look for en, then pl, otherwise nothing.
  • [email protected]:pl:. => Look for en, then pl, then untagged, then any language.
  • [email protected]* => Look for all the values of this predicate and return them along with their language. For example, if there are two values with languages en and hi, this query will return two keys named “[email protected]” and “[email protected]”.

In functions, language lists (including the @* notation) are not allowed. Untagged predicates, Single language tags, and . notation work as described above.

In full-text search functions (alloftext, anyoftext), when no language is specified (untagged or @.), the default (English) full-text tokenizer is used. This does not mean that the value with the en tag will be searched when querying the untagged value, but that untagged values will be treated as English text. If you don’t want that to be the case, use the appropriate tag for the desired language, both for mutating and querying the value.

Query Example: Some of Bollywood director and actor Farhan Akhtar’s movies have a name stored in Russian as well as Hindi and English, others do not.

curl -H "Content-Type: application/dql" localhost:8080/query -XPOST -d '
blahblah' | python -m json.tool | less
package main

import (

var (
	dgraph = flag.String("d", "", "Dgraph Alpha address")

func main() {
	conn, err := grpc.Dial(*dgraph, grpc.WithInsecure())
	if err != nil {
	defer conn.Close()

	dg := dgo.NewDgraphClient(api.NewDgraphClient(conn))
	resp, err := dg.NewTxn().Query(context.Background(), `blahblah`)
	if err != nil {
	fmt.Printf("Response: %s\n", resp.Json)
import io.dgraph.DgraphClient;
import io.dgraph.DgraphGrpc;
import io.dgraph.DgraphGrpc.DgraphStub;
import io.dgraph.DgraphProto.Response;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;

import java.util.Map;

public class App {

    public static void main(final String[] args) {
        ManagedChannel channel =
            ManagedChannelBuilder.forAddress("localhost", 9080).usePlaintext(true).build();
        DgraphStub stub = DgraphGrpc.newStub(channel);
        DgraphClient dgraphClient = new DgraphClient(stub);

        String query = "blahblah";

        Response res = dgraphClient.newTransaction().query(query);
        System.out.printf("Response: %s", res.getJson().toStringUtf8());

import pydgraph
import json

def main():
    client_stub = pydgraph.DgraphClientStub("localhost:9080")
    client = pydgraph.DgraphClient(client_stub)
    query = """blahblah"""
    res = client.txn(read_only=True).query(query)
    print('Response: {}'.format(json.loads(res.json)))


if __name__ == '__main__':
    except Exception as e:
        print('Error: {}'.format(e))

const dgraph = require("dgraph-js");
const grpc = require("grpc");

async function main() {
  const clientStub = new dgraph.DgraphClientStub("localhost:9080", grpc.credentials.createInsecure());
  const dgraphClient = new dgraph.DgraphClient(clientStub);

  const query = `blahblah`;
  const response = await dgraphClient.newTxn().query(query);
  console.log("Response: ", JSON.stringify(response.getJson()));


main().then().catch((e) => {
  console.log("ERROR: ", e);
const dgraph = require("dgraph-js-http");

async function main() {
  const clientStub = new dgraph.DgraphClientStub("http://localhost:8080");
  const dgraphClient = new dgraph.DgraphClient(clientStub);

  const query = `blahblah`;
  const response = await dgraphClient.newTxn().query(query);
  console.log("Response: ", JSON.stringify(;

main().then().catch((e) => {
  console.log("ERROR: ", e);