How to add multiple literal values for one uid predicate?

Many times we need to add two or more literal values for one uid predicate, for example, the same movie may have three to four translations in different regions, but the translated name is not suitable as a separate node, in the search process, we need to get the information of this movie through any translated name. How can i handle this situation with one predicate and many literal values?

Sorry, this question is unclear. What you mean by “literal values for one uid predicate”?

You don’t need a node we support langs

Do you want to use list[string] type in facets ?

how can i use list type in facets? and i also want to know how to add nodes to facets, eg, i want to know who changed the value, and the value is the literal, then i should add node to the facets, but at this version i don’t know how to do that

As far I know you can’t. But why list on facets?

Not sure about the question. You can’t add a node to a facet. But add a facet to a node or between nodes.

in my application scenario, i want to use other nodes as facets. For example, i use one node representing the city, which contains name, location, population, etc. In the graph i need to mark the person who recorded the population, if i use facet, where can i record the person node, or is there any better way to record the person node?

I think the follow solution maybe useful for you.
you can establish edge relationship between the person node and city node, the RDF maybe like this

_: <your city id> <city.person> _:<your person id>
_: <your person id> <> “your person id”
_: <your person id> <> “your person name”
_: <your city id> <> _: “your city id”
_: <your city id> <> “city name”
_: <your city id> <city.location> " location of the city"

and you can get person name who in this city and the city information by query

func_name(func:eq(,"query city id")){

ps: i don’t know how to format the code… so it in a terrible format now

In this sample if the city population has changed, but i should know the new number and the original number of population and i should know who record the number , how can i do this ? The number of population is literal.

I think you can add timestamp in facets, and when you need population in some period,simply filter and count it.

_: <your city id> <city.person> _:<your person id>(move_in=timestamp,move_out=timestamp)

and query

population( func: eq (,"query city id")){
    city.person @facets(gt(move_in,timestamp) and lt(move_out,timestamp)){

Pure Facets are not suitable. It works, but you’ll have more work to do. The ideal is to create an intermediate graph level if you need to keep a historical data. And then in your queries make aggregations to know the total population. In the data nodes you’ll have the new value, other values (like “create_at” so on) and also who added it (an edge pointing to them).

You can also use Facets with an intermediate graph level, but I can’t see why. As Filters can do the same work. You can use Facets to hide some values in the query. But technically it would have the same effect as @filter.

The good thing about facets in this case is that the values contained in it are automatically deleted at one time when you delete the edge. Another detail is that modifications are tricky in facets today. That’s why they’re not suitable at first.

1 Like