ArangoDB-Community / ArangoBnB

16 stars 3 forks source link

Backend: Reviews Language Data Modeling #29

Open cw00dw0rd opened 3 years ago

cw00dw0rd commented 3 years ago

Evaluate reviews to determine the language and split them out into separate collections. We would then link these collections to a view.

The purpose of this is to solve the problem of not know which languages your data contains and how to still be able to evaluate them with a single view.

Simran-B commented 3 years ago

Could create a UDF using a JS library like one of the following (assuming they don't use Promises or similar):

But if you want to move the documents to different collections then AQL can be a bit of a pain and it might be easier to use Node.js + arangojs to run a one-off language detection.

We also thought about using AQL Analyzers (one per language) and only let the comments in one language through, but AQL Analyzers cannot be used in combination with UDFs and they only have access to the value of the field they access, not the entire document (i.e. cannot base the decision of whether to include a comment or not on a separate language field). The only workaround that came to mind was to have a single comment field with an array, where one element is the language and the other the comment text. However, we would like to show that Views can link multiple collections, and this is a good opportunit.