This example works for me:
import pydgraph
stub = pydgraph.DgraphClientStub('localhost:9080')
client = pydgraph.DgraphClient(stub)
client.alter(pydgraph.Operation(drop_all=True))
schema = """
name: string @index(exact) .
friend: [uid] @reverse .
age: int .
married: bool .
loc: geo .
dob: datetime .
type Person {
name
friend
age
married
loc
dob
}
"""
client.alter(pydgraph.Operation(schema=schema))
but when I attempt to add an index to any additional fields it fails:
client.alter(pydgraph.Operation(drop_all=True))
schema = """
name: string @index(exact) .
friend: [uid] @reverse .
age: int @index .
married: bool .
loc: geo .
dob: datetime .
type Person {
name
friend
age
married
loc
dob
}
"""
client.alter(pydgraph.Operation(schema=schema))
_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNKNOWN
details = "line 4 column 10: Require type of tokenizer for pred: age for indexing."
debug_error_string = "{"created":"@1639514595.697355000","description":"Error received from peer ipv6:[::1]:9080","file":"src/core/lib/surface/call.cc","file_line":1064,"grpc_message":"line 4 column 10: Require type of tokenizer for pred: \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000age for indexing.","grpc_status":2}"
>
I think this should be a pretty basic thing but I can’t find any examples of how to do this. Thanks for any help you can provide!