Skip to content

Commit

Permalink
Support OR and AND search, make AND default
Browse files Browse the repository at this point in the history
The search filter now supports OR and AND searches.
Entering multiple words results in AND concatenation, searching for
exact match requires surrounding with '' (e.g. 'Journal of')
  • Loading branch information
white-gecko committed Jan 27, 2014
1 parent 5a91642 commit bf7455d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions library/Erfurt/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,15 @@ public function getSearchPattern($stringSpec, $graphUris, $options = array())

// TODO stringSpec should be more than simple string (parse for and/or/xor etc...)
$stringSpec = (string) $stringSpec;
if (strpbrk($stringSpec, '\'') === false) {
$parts = explode(' ', $stringSpec);
$stringSpec = '';
foreach ($parts as $word) {
$stringSpec.= '\'' . $word . '\' AND ';
}
// Remove the last AND (including whitespace)
$stringSpec = substr($stringSpec, 0, strlen($stringSpec)-5);
}

$options = array_merge(
array(
Expand Down
2 changes: 1 addition & 1 deletion library/Erfurt/Store/Adapter/Virtuoso.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ public function getSearchPattern($stringSpec, $graphUris, $options)
*/
new Erfurt_Sparql_Query2_Function(
$bifContains,
array($objectVariable, new Erfurt_Sparql_Query2_RDFLiteral($stringSpec, null, '"\''))
array($objectVariable, new Erfurt_Sparql_Query2_RDFLiteral($stringSpec))
)
)
)
Expand Down

0 comments on commit bf7455d

Please sign in to comment.