問題描述
Marklogic Java API 語義三重搜索 (Marklogic Java API Semantic Triple Search)
我將 json 文檔插入服務器並使用該文檔創建了三元組。使用 SPARQL 處理三元組並將新的三元組作為輸出插入到集合中。現在我想在三元組集合中搜索。像 Java Client api(google like)中的文檔搜索一樣,可以三元組搜索嗎?如果不是,請針對上述情況提出任何解決方案。
參考解法
方法 1:
You have multiple powerful options at your disposal here. I'll highlight two:
- Search your original JSON documents Using String Query Definition (google like)
- Use SPARQLQueryManager to run SPARQL queries only on documents which match your google‑like string query
I suggest you do either on a collection holding your original JSON documents, because you know exactly what's in each one and how your string queries will match. If you instead query the collection containing triples you created with SPARQL, those are managed triples which means many triples are in one document so your constraining queries won't narrow as precisely.
If you really want to search your managed triples you could use this more precise but less efficient approach:
- Use built‑in functions in a SPARQL Query with cts:contains
方法 2:
There is always the MarkLogic Query Console (http://localhost:8000/qconsole/). Create a new tab, choose the Query type as SPARQL Query (or Update), and choose the Content Source containing the triples.
Place the SPARQL query in the body of the Query console and the query will be executed across all triples in the selected Content Source/
(by Logesh、Sam Mefford、scotthenninger)