Open leipert opened 10 years ago
@Aklakan I propose the following structure for a sponate language filter. Imagine you have the following JSON result from a SPARQL request:
{
"head": {
"link": [],
"vars": ["id", "a", "b", "c"]
},
"results": {
"distinct": false,
"ordered": true,
"bindings": [
{
"id": { "type": "uri", "value": "http://e.org/a" },
"a": { "type": "literal", "value": "No Language" },
"b": { "type": "literal", "xml:lang": "de", "value": "Deutsch" },
"c": { "type": "literal", "xml:lang": "en", "value": "Only en" }
},
{
"id": { "type": "uri", "value": "http://e.org/a" },
"a": { "type": "literal", "value": "No Language" },
"b": { "type": "literal", "xml:lang": "en", "value": "Englisch" },
"c": { "type": "literal", "xml:lang": "en", "value": "Only en" }
},
]
}
}
Only one language:
var langFilter = {$lang: 'de'}
var criteria = {a: langFilter, b: langFilter, c: langFilter}
var flow = store.example.find(criteria)
flow.asList()
.done(function(docs) {
console.log(docs);
});
// Prints
// [{id: "http://e.org/a", a: null, b: "Deutsch", c: null}]
Multiple Languages in prefered order:
var langFilter = {$lang: ['de','en']}
var criteria = {a: langFilter, b: langFilter, c: langFilter}
var flow = store.example.find(criteria)
flow.asList()
.done(function(docs) {
console.log(docs);
});
// Prints
// [{id: "http://e.org/a", a: null, b: "Deutsch", c: "Only en"}]
With wildcard:
var langFilter = {$lang: ['de','en','*']}
var criteria = {a: langFilter, b: langFilter, c: langFilter}
var flow = store.example.find(criteria)
flow.asList()
.done(function(docs) {
console.log(docs);
});
// Prints
// [{id: "http://e.org/a", a: "No Language", b: "Deutsch", c: "Only en"}]
looks much better than