1 | <?php |
||
10 | class JenaTextSparql extends GenericSparql |
||
11 | { |
||
12 | /** |
||
13 | * How many results to ask from the jena-text index. jena-text defaults to |
||
14 | * 10000, but that is too little in some cases. |
||
15 | * See issue reports: |
||
16 | * https://code.google.com/p/onki-light/issues/detail?id=109 (original, set to 1000000000) |
||
17 | * https://github.com/NatLibFi/Skosmos/issues/41 (reduced to 100000 because of bad performance) |
||
18 | */ |
||
19 | const MAX_N = 100000; |
||
20 | |||
21 | /* |
||
22 | * Characters that need to be quoted for the Lucene query parser. |
||
23 | * See http://lucene.apache.org/core/4_10_1/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Escaping_Special_Characters |
||
24 | */ |
||
25 | const LUCENE_ESCAPE_CHARS = ' +-&|!(){}[]^"~?:\\/'; /* note: don't include * because we want wildcard expansion |
||
26 | |||
27 | /** |
||
28 | * Make a jena-text query condition that narrows the amount of search |
||
29 | * results in term searches |
||
30 | * |
||
31 | * @param string $term search term |
||
32 | * @param string $property property to search (e.g. 'skos:prefLabel'), or '' for default |
||
33 | * @param string @$searchLang for language code |
||
34 | * @return string SPARQL text search clause |
||
35 | */ |
||
36 | |||
37 | private function createTextQueryCondition($term, $property = '', $searchLang = '') |
||
61 | |||
62 | /** |
||
63 | * Generate jena-text search condition for matching labels in SPARQL |
||
64 | * @param string $term search term |
||
65 | * @param string $langClause language clause used for matching labels (null means any language) |
||
66 | * @return string sparql query snippet |
||
67 | */ |
||
68 | protected function generateConceptSearchQueryCondition($term, $langClause) |
||
80 | |||
81 | /** |
||
82 | * This function generates jenatext language clauses from the search language tag |
||
83 | * @param string $lang |
||
84 | * @return string formatted language clause |
||
85 | */ |
||
86 | protected function generateLangClause($lang) { |
||
89 | |||
90 | |||
91 | /** |
||
92 | * Generates sparql query clauses used for ordering by an expression. Uses a special collation function |
||
93 | * if configuration for it is enabled. |
||
94 | * @param string $expression the expression used for ordering the results |
||
95 | * @param string $lang language |
||
96 | * @return string sparql order by clause |
||
97 | */ |
||
98 | private function formatOrderBy($expression, $lang) { |
||
105 | |||
106 | /** |
||
107 | * Generates the jena-text-specific sparql query used for rendering the alphabetical index. |
||
108 | * @param string $letter the letter (or special class) to search for |
||
109 | * @param string $lang language of labels |
||
110 | * @param integer $limit limits the amount of results |
||
111 | * @param integer $offset offsets the result set |
||
112 | * @param array|null $classes |
||
113 | * @param boolean $showDeprecated whether to include deprecated concepts in the result (default: false) |
||
114 | * @param \EasyRdf\Resource|null $qualifier alphabetical list qualifier resource or null (default: null) |
||
115 | * @return string sparql query |
||
116 | */ |
||
117 | |||
118 | public function generateAlphabeticalListQuery($letter, $lang, $limit = null, $offset = null, $classes = null, $showDeprecated = false, $qualifier = null) |
||
173 | |||
174 | } |
||
175 |