Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Es solr support 12 #39

Open
wants to merge 26 commits into
base: es-solr-support-12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b517653
Adding changed placeholder prefix to readme
sdrenth Jan 18, 2019
3a40d62
Add all placeholders to noresults tpl
sdrenth Feb 18, 2019
2607052
Pagination fix when using faceted search
sdrenth Feb 18, 2019
a99ae9b
Fixing setting correct parameters for paging links
sdrenth Feb 18, 2019
a430c90
FIX: Pagination Next and Last links do not render while using pageLim…
Feb 22, 2019
09bcb7c
FIX: Bad characters in extract due to preg_replace with php 7.0 and l…
Mar 6, 2019
6619fe5
Fix search on tvs
MrRoco Mar 8, 2019
db921ca
Add new package
MrRoco Mar 8, 2019
0f7d806
Merge pull request #17 from Sterc/fix-13
MrRoco Mar 15, 2019
b4181b4
Fix no results when facet has result but default does not
MrRoco Mar 15, 2019
05d69e7
Merge branch 'development' into noresultstpl-all-phs
MrRoco Mar 15, 2019
fec2a53
Merge pull request #19 from Sterc/noresultstpl-all-phs
MrRoco Mar 15, 2019
250d86f
Merge pull request #20 from Sterc/simplesearch-facetsearch-pagination…
MrRoco Mar 15, 2019
483d527
Merge pull request #21 from Sterc/fix-setting-correct-paginglink-params
MrRoco Mar 15, 2019
0eca8f3
Merge pull request #23 from smahelos/fix-next-and-last-links
MrRoco Mar 15, 2019
0821dd4
Merge pull request #25 from smahelos/bad-characters-in-extract
MrRoco Mar 15, 2019
f71f5ab
Merge pull request #26 from Sterc/master
MrRoco Mar 15, 2019
7f11ae3
Fix coding standards
MrRoco Mar 15, 2019
9241ec2
Fix some more coding standards
MrRoco Mar 15, 2019
31795de
New release for simplesearch
MrRoco Mar 15, 2019
cbb0ee2
Merge pull request #27 from Sterc/development
MrRoco Mar 15, 2019
3b447db
Update README.md
gpsietzema Jul 2, 2019
fed4c12
Merge branch 'master' into es-solr-support-12
travisbotello Jul 5, 2020
42fbde9
Fixed wrong driver call
Jul 6, 2020
602a566
Modified some elastica calls
Jul 6, 2020
4ddb505
Fixed wrong inclusion
Jul 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Upgrading to 2.0.0 from 1.* is highly recommended, but it does introduce some ri

Important changes from 1.* to 2.0.0:
- The namespace has been changed from `sisea` to `simplesearch`. If you're using custom System Settings, then please migrate them.
- The placeholder prefix has also been changed from `sisea` to `simplesearch`.
- The ElasticSearch and SOLR drivers have been removed, because they were in need of improvements. Future drivers should be seperate addons. Feel free to ask us for help here.

## Autosuggest
Expand All @@ -35,3 +36,8 @@ $('.simplesearch-search-form input[type="text"]').on('keyup', function () {

## Bugs and feature requests
We value your feedback, feature requests and bug reports. Please issue them on [Github](https://github.com/Sterc/SimpleSearch/issues/new).

# Free Extra
This is a free extra and the code is publicly available for you to change. The extra is being actively maintained and you're free to put in pull requests which match our roadmap. Please create an issue if the pull request differs from the roadmap so we can make sure we're on the same page.

Need help? [Approach our support desk for paid premium support.](mailto:[email protected])
2 changes: 1 addition & 1 deletion _build/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"lowCaseName": "simplesearch",
"description": "A simple search solution for MODX Revolution. Loosely based on AjaxSearch for Evolution (minus the ajax). Only searches Resources; does not search dynamic content.",
"author": "Sterc",
"version": "2.1.0-pl",
"version": "2.1.2-pl",
"package":{
"elements": {
"chunks": [{
Expand Down
Binary file added _packages/simplesearch-2.1.1-pl.transport.zip
Binary file not shown.
Binary file added _packages/simplesearch-2.1.2-pl.transport.zip
Binary file not shown.
12 changes: 11 additions & 1 deletion core/components/simplesearch/docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
Changelog for SimpleSearch.

SimpleSearch 2.1.2
========================================================================
- Show facet results when default has none.
- Have all placeholders in no result page
- Fix pagination for pageLimit & facet search

SimpleSearch 2.1.1
========================================================================
- Fix includeTVList bug to show normal search results as well.

SimpleSearch 2.1.0
========================================================================
- Added pdoParser support
Expand Down Expand Up @@ -52,7 +62,7 @@ SimpleSearch 1.8.0
- Added support to ElasticSearch driver for using search fields
- Added support to ElasticSearch driver for boosting results by a field value
- Updated Elastica to v0.90.7.0
- Added outputSeparator option
- Added outputSeparator option

SimpleSearch 1.7.0
========================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
* @package simplesearch
*/
require_once $modx->getOption(
'simplesearch.core_path',
null,
$modx->getOption('core_path') . 'components/simplesearch/'
) . 'model/simplesearch/simplesearch.class.php';
'simplesearch.core_path',
null,
$modx->getOption('core_path') . 'components/simplesearch/'
) . 'model/simplesearch/simplesearch.class.php';
$search = new SimpleSearch($modx, $scriptProperties);

/* Find search index and toplaceholder setting */
Expand Down Expand Up @@ -54,12 +54,13 @@
$offsetIndex = $modx->getOption('offsetIndex', $scriptProperties, 'simplesearch_offset');
$idx = isset($_REQUEST[$offsetIndex]) ? (int) $_REQUEST[$offsetIndex] + 1 : 1;
$postHooks = $modx->getOption('postHooks', $scriptProperties, '');
$activeFacet = $modx->getOption('facet',$_REQUEST,$modx->getOption('activeFacet', $scriptProperties, 'default'));
$activeFacet = $modx->getOption('facet', $_REQUEST, $modx->getOption('activeFacet', $scriptProperties, 'default'));
$activeFacet = $modx->sanitizeString($activeFacet);
$facetLimit = $modx->getOption('facetLimit', $scriptProperties, 5);
$outputSeparator = $modx->getOption('outputSeparator', $scriptProperties, "\n");
$addSearchToLink = (int) $modx->getOption('addSearchToLink', $scriptProperties, 0);
$searchInLinkName = $modx->getOption('searchInLinkName', $scriptProperties, 'search');
$noResults = true;

/* Get results */
$response = $search->getSearchResults($searchString, $scriptProperties);
Expand Down Expand Up @@ -87,7 +88,7 @@
$text = $modx->runSnippet($extractSource, $resourceArray);
}

$extract = $search->createExtract($text,$extractLength,$extract,$extractEllipsis);
$extract = $search->createExtract($text, $extractLength, $extract,$extractEllipsis);

/* Cleanup extract */
$extract = strip_tags(preg_replace("#\<!--(.*?)--\>#si", '', $extract));
Expand Down Expand Up @@ -131,7 +132,7 @@
foreach ($facetResults['results'] as $r) {
$r['idx'] = $idx;
$fTpl = !empty($scriptProperties['tpl' . $facetKey]) ? $scriptProperties['tpl' . $facetKey] : $tpl;
$resultsTpl[$facetKey]['results'][] = $search->getChunk($fTpl,$r);
$resultsTpl[$facetKey]['results'][] = $search->getChunk($fTpl, $r);
$idx++;
}
}
Expand All @@ -141,18 +142,22 @@
/* Set faceted results to placeholders for easy result positioning. */
$output = array();
foreach ($resultsTpl as $facetKey => $facetResults) {
$resultSet = implode($outputSeparator,$facetResults['results']);
$resultSet = implode($outputSeparator, $facetResults['results']);
$placeholders[$facetKey.'.results'] = $resultSet;
$placeholders[$facetKey.'.total'] = !empty($facetResults['total']) ? $facetResults['total'] : 0;
$placeholders[$facetKey.'.key'] = $facetKey;

if ($placeholders[$facetKey.'.total'] !== 0) {
$noResults = false;
}
}

$placeholders['results'] = $placeholders[$activeFacet . '.results']; /* Set active facet results. */
$placeholders['total'] = !empty($resultsTpl[$activeFacet]['total']) ? $resultsTpl[$activeFacet]['total'] : 0;
$placeholders['page'] = isset($_REQUEST[$offsetIndex]) ? ceil((int) $_REQUEST[$offsetIndex] / $perPage) + 1 : 1;
$placeholders['pageCount'] = !empty($resultsTpl[$activeFacet]['total']) ? ceil($resultsTpl[$activeFacet]['total'] / $perPage) : 1;

if (!empty($response['results'])) {
if (!empty($placeholders['results'])) {
/* add results found message */
$placeholders['resultInfo'] = $modx->lexicon('simplesearch.results_found', array(
'count' => $placeholders['total'],
Expand All @@ -161,7 +166,7 @@

/* If perPage set to >0, add paging */
if ($perPage > 0) {
$placeholders['paging'] = $search->getPagination($searchString,$perPage,$pagingSeparator,$placeholders['total']);
$placeholders['paging'] = $search->getPagination($searchString, $perPage, $pagingSeparator, $placeholders['total']);
}
}

Expand All @@ -173,12 +178,10 @@
$modx->setPlaceholder($placeholderPrefix . 'count', $response['total']);
$modx->setPlaceholders($placeholders, $placeholderPrefix);

if (empty($response['results'])) {
$output = $search->getChunk($noResultsTpl, array(
'query' => $searchString,
));
if ($noResults) {
$output = $search->getChunk($noResultsTpl, $placeholders);
} else {
$output = $search->getChunk($containerTpl, $placeholders);
}

return $search->output($output, $toPlaceholder);
return $search->output($output, $toPlaceholder);
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
*
* @package simplesearch
*/
require_once __DIR__ . '/simplesearchdriverbasic.class.php';

require_once strtr(realpath(dirname(__DIR__)), '\\', '/') . '/simplesearchdriverbasic.class.php';
class SimpleSearchDriverBasic_mysql extends SimpleSearchDriverBasic {}
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,25 @@ public function search($str, array $scriptProperties = []) {
$docFields = explode(',', $this->modx->getOption('docFields', $scriptProperties, 'pagetitle,longtitle,alias,description,introtext,content'));
$includeTVs = $this->modx->getOption('includeTVs', $scriptProperties, false);
$includeTVList = $this->modx->getOption('includeTVList', $scriptProperties, '');
$includedTVIds = array();


$c = $this->modx->newQuery('modResource');
if ($includeTVs) {
$c->leftJoin('modTemplateVarResource', 'TemplateVarResources');
if (!empty($includeTVList)) {
$includeTVList = explode(',', $includeTVList);
$includeTVList = array_map('trim', $includeTVList);
$c->leftJoin('modTemplateVar', 'TemplateVar', array('TemplateVarResources.tmplvarid = TemplateVar.id'));
$c->where(array(
'TemplateVar.name:IN' => $includeTVList
));
$tv = $this->modx->newQuery('modTemplateVar', [
'name:IN' => $includeTVList
]);
$tv->select('id');
$tv->prepare();
$result = $this->modx->query($tv->toSQL());
$tvIds = $result->fetchAll(PDO::FETCH_ASSOC);
foreach ($tvIds as $row) {
$includedTVIds[] = $row['id'];
}
}
}

Expand Down Expand Up @@ -109,6 +117,9 @@ public function search($str, array $scriptProperties = []) {

if ($includeTVs) {
$whereArray[] = array('TemplateVarResources.value:LIKE', $term, xPDOQuery::SQL_OR, $whereGroup);
if (!empty($includeTVList)) {
$whereArray[] = array('TemplateVarResources.tmplvarid:IN', $includedTVIds, xPDOQuery::SQL_AND, $whereGroup);
}
}

if (is_array($customPackages) && !empty($customPackages)) {
Expand All @@ -131,8 +142,12 @@ public function search($str, array $scriptProperties = []) {
foreach ($docFields as $field) {
$whereArray[] = array($field.':LIKE', $term,xPDOQuery::SQL_OR, $whereGroup);
}

$whereArray[] = array('TemplateVarResources.value:LIKE', $term, xPDOQuery::SQL_OR, $whereGroup);
if ($includeTVs) {
$whereArray[] = array('TemplateVarResources.value:LIKE', $term, xPDOQuery::SQL_OR, $whereGroup);
if (!empty($includeTVList)) {
$whereArray[] = array('TemplateVarResources.tmplvarid:IN', $includedTVIds, xPDOQuery::SQL_AND, $whereGroup);
}
}
if (is_array($customPackages) && !empty($customPackages)) {
foreach ($customPackages as $package) {
$fields = explode(',', $package[1]);
Expand Down
Loading