3.7 KiB
3.7 KiB
Querying and displaying data
When resolving a query request (i.e. resolving the parser function {{#ask ... }} or {{#show: ... }}) the QueryEngine has two distinct tasks to accomplish:
- First, build a query condition in a corresponding language (SQL, ES-DSL, SPARQL) that is understood by the assigned QueryEngine where it returns a list of subjects that match the condition (similar to finding rows in a table that match a WHERE condition)
- Secondly, build a
QueryResultobject that contains the matched subjects and provide information on the requested printouts (equivalent of columns displayed in a table)
src/ParserFunctions
AskParserFunction.phpdefines the#askparser functionShowParserFunction.phpdefines the#showparser function
src/Query
Parser.phpinterface tosrc/Query/Parserto create aDescriptionandQueryobject from an{{#ask: ...}}stringPrintRequest.phpResultPrinter.phpinterface to concrete implementations found insrc/Query/ResultPrinters
src/Query/Language
Each condition element (e.g. [[Has foo::bar]] || [[!Foo]]) of a query is represented by a Description object allowing to express a query condition as as description AST.
src/Query/Result
- [
QueryResult.php] the instance represents the matched subjects of a query request (i.e. rows of a table) - [
ResultArray.php] represents a lazy-object to contain the printouts (seePrintRequest) for a particular subject (i.e. as columns for a particular row)
src/Query/ResultPrinters
A ResultPrinter is the user facing output formatter that takes a QueryResult and transform its representation into a specific format by extending:
ResultPrinter.phpis an abstract base class to provide accessors and pre and postprocess the output after an individual printer returns the formatted result orFileExportPrinter.phpis an abstract base class for file export result printers
Examples
boilerplate.resultprinterstarting point for writing a result printerboilerplate.fileexportprinterstarting point for writing a file result printerboilerplate.resultprinter.examplea complete examplequery.description.mdhow to build aDescripionobjectsquery.someproperty.of.type.number.mdexample on how to query a number