String escaping and language fulltext search question

Hi, there. I am a beginner to dgraph club and I meet two problems when I learn and use dgraph.

The first one is, is there some way to handle character escaping. For example, quotation marks inside the string quotation marks. I’d like to store a JSON string as an attribute value. This will raise a mutation error.

The second one is, in Fulltext searching, is there any difference between indexing the predicates with language and mark @lang in my predicate when I create a mutation and not doing so, specifically non-English language.

Thanks a lot,

Hi @kehan1 welcome to Dgraph community.

first question
If we have a type like this:

type Something {
  SomethingID: ID!

I can add my JSON field like this:

mutation createSomething {
  addSomething(input: {jsonField: "{\"name\": \"Kehan\"}"}) {
    something {

And for example if I parse this string with Javascript JSON.parse:

JSON.parse("{\"name\": \"hasan\"}")

This will be the result: Object { name: "hasan" }

Second question
Having language index on your predicate will let you execute queries based on the language of inserted field. This article and video might help you with multi-language:

When you have a field that you want to fill it with different languages, by adding @lang index you can provide more information about the language. It is not related to full text search as far as I’m concerned but you can execute queries to find that field in specific language.

1 Like