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.
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: https://dgraph.io/docs/tutorial-4/
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.
Hi Poorshad, thanks for replying.
For more details about the first one besides JSON object, if I have a type Person, it has an attribute name, like the example below.
type Person{
name
}
name: string @index(hash) .
When I insert data like,
{ set {
_:myName <name> " "Kehan" " .
}}
this will raise a mutation error, so I am doing character escaping manually, like " “Kehan” ".
Is there any built-in method to take care of it? Like we have a parameter function to handle character escaping when we use DQL to search it, example below. This is a big problem for me since I have a big size of string data to insert. Except of quotation marks, \n/\r raises this error as well.
# reference from *https://dgraph.io/docs/clients/python/*
query = """query all($a: string) {
all(func: eq(name, $a))
{
name
}
}"""
variables = {'$a': 'Alice'}
res = txn.query(query, variables=variables)