Git Product home page Git Product logo

simplesearchcustomdriver's Introduction

SimpleSearchCustomDriver

Examples of custom drivers for the extra SimpleSearch.

Custom Driver

This driver runs the search more efficiently than the default SimpleSearch driver, if TVs are used.

Usage:

Set the system setting simplesearch.driver_class to SimpleSearchCustomDriver\Driver\Custom.

Additional features:

  • Fields from custom tables are available in the output. (The Placeholders have the class alias as the prefix: [[+testpackageItem.title]].)
  • Fields from custom tables can be used in the property fieldPotency. (Include the class alias as the prefix.)
[[!SimpleSearchForm]]
<h2>Results</h2>
[[!SimpleSearch?
    ...
    &customPackages=`Testpackage\Model\testpackageItem:title:::testpackageItem.resource = modResource.id`
    &fieldPotency=`content:10,sometv:5,testpackageItem.title:20`
]]
  • The results can be sorted by TVs (that are listed in the property includeTVList) or fields from a custom table.
[[!SimpleSearchForm]]
<h2>Results</h2>
[[!SimpleSearch?
    ...
    &includeTVList=`sometv,someothertv`
    &sortBy=`sometv`
    &sortDir=`desc`
]]
  • Custom filters can be added with the property where.
[[!SimpleSearchForm]]
<h2>Results</h2>
[[!SimpleSearch?
    ...
    &where=`{"template:IN":[1,2,3]}`
]]
  • Set a maximun amount of results to be sorted in PHP using the fieldPotency property. This avoids the loading of a huge amount of data from the database, if someone searches for a very common search term.
[[!SimpleSearchForm]]
<h2>Results</h2>
[[!SimpleSearch?
    ...
    &maxCountPhpSort=`200`
    &sortBy=``
    &fallbackSortBy=`publishedon`
    &sortDir=`desc`
]]
  • For debugging purposes, the generated SQL query is set as a placeholder. The placeholder [[+score]] is added to the template to check the score calculation.
<pre>[[!+SimpleSearchCustomDriver.SQL]]</pre>

[[!SimpleSearchForm]]
<h2>Results</h2>
[[!SimpleSearch?
    ...
    &debug=`1`
]]

Different behavior

The property &includeTVs=`1` can't be used in this driver to search in all available TVs. Only the TVs listed in the property includeTVList are used for the search and the sorting.

PdoFetchDriver

This driver uses the class pdoFetch (from the extra pdoTools) to query the data.

Usage:

Set the system setting simplesearch.driver_class to SimpleSearchCustomDriver\Driver\PdoFetchDriver.

Additional features:

  • Fields from custom tables are available in the output. (The Placeholders have no prefix: [[+title]].)
  • Fields from custom tables can be used in the property fieldPotency.
[[!SimpleSearchForm]]
<h2>Results</h2>
[[!SimpleSearch?
    ...
    &customPackages=`Testpackage\Model\testpackageItem:title:::testpackageItem.resource = modResource.id`
    &fieldPotency=`content:10,sometv:5,title:20`
]]
  • The results can be sorted by TVs (listed in the property includeTVList) or fields from a custom table.
[[!SimpleSearchForm]]
<h2>Results</h2>
[[!SimpleSearch?
    ...
    &includeTVList=`sometv,someothertv`
    &sortBy=`sometv`
    &sortDir=`desc`
]]
  • Custom filters can be added with the property where.
[[!SimpleSearchForm]]
<h2>Results</h2>
[[!SimpleSearch?
    ...
    &where=`{"template:IN":[1,2,3]}`
]]
  • Output debug information from pdoFetch (to check the generated SQL query).
<pre>[[!+pdoFetchLog]]</pre>

[[!SimpleSearchForm]]
<h2>Results</h2>
[[!SimpleSearch?
    ...
    &debug=`1`
]]

Different behavior

The property &includeTVs=`1` can't be used in this driver to search in all available TVs. Only the TVs listed in the property includeTVList are used for the search and the sorting.

Also, the default values of TVs are not taken into account for the search.

simplesearchcustomdriver's People

Contributors

halftrainedharry avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.