new semanticcontext()
Semantic context object for finding entities and drilling down in to relationships. Abstracts performing SPARQL. Allows Caching of entity facts whilst browsing.
Methods
-
<static> getConfigurationDefinition()
-
Returns the MLJS Workplace Context Configuration definition JSON object
-
getContentContext() → {searchcontext}
-
Returns the (content) search context instance (or null) that this semantic context is configured to update
Returns:
context - The searchcontext instance (or null) that this semantic context will update
- Type
- searchcontext
-
getContentMode() → {string}
-
Returns this context's content search contribution mode. Either 'full' (default) or 'contribute'.
Returns:
contentMode - The mode of this semantic context's contribution to a search context's structured query
- Type
- string
-
getFact(subjectIri, predicate, reload_opt)
-
Looks up a single fact. Checks the fact cache first. Fires an updateSubjectFacts event.
Parameters:
Name Type Description subjectIri
string The IRI of the subject whose fact we are looking for
predicate
string The predicate IRI of the fact to locate
reload_opt
string Whether to reload the fact, or use the cached value (if it exists) - defaults to false (use cache)
-
getFacts(subjectIri, reload_opt)
-
Fetches all facts for a specified subject. Fires an updateSubjectFacts event.
Parameters:
Name Type Description subjectIri
string The IRI of the subject whose fact we are looking for
reload_opt
string Whether to reload the fact, or use the cached value (if it exists) - defaults to false (use cache)
-
getFactsWhere(whereSparql)
-
Get facts for the Subject where the given condition matches. MUST use ?subject for the subject of interest.
Parameters:
Name Type Description whereSparql
string The Sparql to embed within the where clause using ?subject
-
getTripleConfiguration() → {tripleconfig}
-
Returns the underlying triple config instance.
Returns:
config - The tripleconfig being used to generate SPARQL by this semanticcontext
- Type
- tripleconfig
-
hasContentContext() → {boolean}
-
Determines whether this semantic context is set up to update a (content) search context.
Returns:
hasContentContext - true if this context is configured to update a (content) search context
- Type
- boolean
-
moveOffset(offset)
-
Changes the configured search offset. Useful for paging
Parameters:
Name Type Description offset
integer the search results paging offset
-
primeSimpleSuggest()
-
This seems to kick the sparql query cache in to action. Even doing this for a different RdfType seems to help. This is really only applicable to demonstrations rather than production systems, as in production MarkLogic's triple algorithms over time change algorithms to a near-best option, and caches this for 10 minutes.
-
queryFacts(sparql)
-
Fetches arbitrary facts as requested by the specified sparql. Could return any bindings. Fires an updateFacts event. NB this method does not specify its own OFFSET or LIMIT values.
Parameters:
Name Type Description sparql
string The sparql to use to locate facts
-
register(obj)
-
Registers an object with this semantic context. This checks for the following general methods: setSemanticContext And event handlers: updateSubjectResults, updateSubjectFacts, updateFacts, updateSuggestions And event firers: addSubjectSelectionListener
Note that this context will automatically register the specified object with the dependant (content) search context, if one is configured.
Parameters:
Name Type Description obj
object The object to register with this context
-
setConfiguration(config)
-
Sets the configuration of this context using the MLJS Workplace JSON format.
Parameters:
Name Type Description config
JSON The JSON configuration of this context.
-
setContentContext(ctx)
-
Sets the content context to update (if any) with #uris via a document-query
Parameters:
Name Type Description ctx
searchcontext The (Content) Search Context to update
-
setContentMode(mode)
-
Sets the mode for this context. This affects how this context updates a searhcontext's content search when it finds Subjects related to a MarkLogicDocument. See details on the MarkLogic sample ontology for details. This context will take the #uri value of a subject(or subjects) and generate an or-query of document-query(uri) within the target search context.
Parameters:
Name Type Description mode
string The structured query builder mode - full (default) or 'contribute'. Affects whether this context calls searchcontext's doStructuredQuery or contributeStructuredQuery instead
-
setTripleConfiguration() → {tripleconfig}
-
Sets the triple config instance to use for determining ontology information.
Returns:
config - The triple config instance used
- Type
- tripleconfig
-
simpleSuggest(subjectIri, predicate, startString_opt)
-
Performs a suggestion lookup for a fact value using SPARQL. NB limited to 10 distinct suggestions. NB only does a simple string match, so doesn't take in to account value type (E.g. Integer) TODO update to use tripleconfig to determine type, if information is available.
Parameters:
Name Type Description subjectIri
string The IRI of the subject whose fact we are looking for
predicate
string The predicate IRI of the fact to locate
startString_opt
string If specified, replaces the default FILTER part of the sparql generated
-
subjectContent(subjectIri, docSparql_opt)
-
Looks up related content to the specified Subject. TODO update this to also check MarkLogicDocument #uri rather than just a docuri as an intrinsic string object value related to the graph. NB Currently supports a maximum list of 10 document URIs, and doesn't use DISTINCT NB only executes if a (content) search context has been configured on this semantic context instance
Parameters:
Name Type Description subjectIri
string The IRI of the subject to fetch related content for
docSparql_opt
string The Sparql to use (should return a ?docuri binding) if not using the default sparql generation within this method
-
subjectFacts(subjectIri)
-
Fetches facts that have the subjectIri specified as the 'subject' (but NOT the 'object - thus different to GET /v1/graphs/things)
Parameters:
Name Type Description subjectIri
string The Subject iri to fetch facts for
-
subjectQuery(sparql, offset_opt, limit_opt)
-
Queries for a subject using the specified SPARQL and paging information. Fires updateSubjectResults.
Parameters:
Name Type Description sparql
string the sparql string (not including OFFSET or LIMIT) to use for the search
offset_opt
integer the offset to use (defaults to 1)
limit_opt
integer the limit to use (defaults to 10)