Giter Site home page Giter Site logo

silverstripe-searchable-dataobjects's People

Contributors

antons- avatar g4b0 avatar muskie9 avatar nblum avatar ntsim avatar rotassator avatar wernerkrauss avatar yusuf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

silverstripe-searchable-dataobjects's Issues

PaginatedList properties are protected..

.. so they can't be set directly in CustomSearch::getSearchResults();

You need to use :
$ret = new PaginatedList($list);
$ret->setPageLength(10);
$ret->setPageStart($s);
$ret->setTotalItems($list->count());
$ret->setLimitItems(10);

SearchableDataObject DB table has multiple keys/indexes

I am getting the following error when attempting to /dev/build with the silverstripe-searchable-dataobjects module installed:

ALTER TABLE SearchableDataObjects ADD FULLTEXT (`Title` ,`Content`) | Too many keys specified; max 64 keys allowed

screen shot 2015-10-07 at 11 08 00

Based on the error I am assuming the issue is in someway related to the following line in SearchableDataObject::augmentDatabase():

DB::query("ALTER TABLE SearchableDataObjects ADD FULLTEXT (Title ,Content)");

I am guessing this query is being run multiple times and a new index/key is being created in the DB each time it is run.

As you can see from the following screenshots (taken in Navicat as MySQL DB management tool) after initially installing the module running /dev/build and /dev/tasks/PopulateSearch I have 24 indexes, then some time later (possibly having changed the current locale for the site) I run another /dev/build and this attempts to increase to > 63 indexes which is what triggers the SQL error.

After initial set up:
screen shot 2015-10-06 at 19 11 28

After a subsequent /dev/build some time later (having switched locale in my config files):
screen shot 2015-10-06 at 18 59 13

I am not familiar with the augmentDatabase() method or where and when it is called otherwise I would investigate further and propose a fix.

This article may be of some help, at very least it helped me track down the issue itself - https://www.safaribooksonline.com/blog/2012/11/06/avoiding-too-many-keys-in-mysql/

Any ideas?

SearchableDataObject does take into account SiteTree versioned

SearchableDataObject::onAfterWrite gives ambigous ID when saving a Page with extra fields.
This fixes the problem for me:

$table = $this->owner->class;
if(is_a($this->owner, 'SiteTree') && Versioned::current_stage() == 'Live') {
$table = 'SiteTree_Live';
}
$filterID = $table . ".ID={$this->owner->ID}";

Error : Class 'HTMLPurifier_Config' not found

Running Task Populate Search

[Emergency] Uncaught Error: Class 'HTMLPurifier_Config' not found
GET /dev/tasks/PopulateSearch

any help?
OK. I found out:
Thats more an issue (?) on Purifier.php

i had to add a require_once right after 'namespace g4b0\HtmlPurifier;':

namespace g4b0\HtmlPurifier;
require_once '../vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php';

sepp.

SearchableDataObject onBeforeDelete override calls parent::onAfterDelete()

I was looking at the code for the onBeforeDelete function on the SearchableDataObject class.

I'm not sure if this is done on purpose or not, but on line 45, it calls parent::onAfterDelete().

It seems to me like parent::onBeforeDelete() should be called in this instance, not parent::onAfterDelete().

Thanks a lot for this plugins. It's really helpful and saved me a lot of time.

Provide own search controller

searching on the current page might be simple but not the most elegant solution.

Also it conflicts with custom $url_handlers like we use when trying to eleminating actions (aka url slug).

Make search form configurable

How about generating search form's fields and actions in seperate methods with hooks for modifying them? E.g. for putting default search text as placeholder instead of value etc...

If you want i can provide a PR for that.

Support for SIlverstripe 5

Many SS4 modules simply require changes to dependency requirements that allow for 5.0 versions of silverstripe core modules in order to run correctly in SS5. That may suffice here, but it will also require upgrading the htmlpurifier module.

mysql error on a fresh install

tryting to deploy my website i get the following error on the very first dev/build on a clean database:

[User Error] Couldn't run query: INSERT INTO SearchableDataObjects (ID, ClassName, Title, Content) VALUES (2, 'Page', 'Über uns', 'Sie können diese Seite mit Ihren eigenen Inhalten füllen, oder sie löschen und Ihre eigenen Seiten erstellen.') ON DUPLICATE KEY UPDATE Title='Über uns', Content='Sie können diese Seite mit Ihren eigenen Inhalten füllen, oder sie löschen und Ihre eigenen Seiten erstellen.' Table 'silverstripe.SearchableDataObjects' doesn't exist

Guess it's cause onAfterPublish hook tries to update the non existent table. Any way to check if the table exists before trying to update?

getSearchFilter null results in addFilter warning

When setting :
public static function getSearchFilter() {
return null;
}

This will result in a warning :
[Warning] Invalid argument supplied for foreach() in DataList->addFilter() ;

using an empty array will fix this :

public static function getSearchFilter() {
return array();
}

Possibility to filter by language or Subsite?

Any chance to get additional fields in the search table, e.g. for subsite/multisite environment or for locale?

How could we easily alter the seach DB? Should we use a DataObject instead? You could still query it manually... Or just with extensions hooks when we generate the table / insert / search ???

readme.md example DataObject class code bug

Hi Gabriele,

Just getting to grips with your module which looks good so far, one thing that has had me stuck trying to get it working for some time was that the readme.md example code of how to set up a DataObject to be searchable contains the following:

    /**
     * FilterByCallback function (optional)
     * eg. function($object){
     *  return ($object->StartDate > date('Y-m-d') || $object->isStillRecurring());
     * };
     * @return array
     */
    public static function getSearchFilterByCallback() {
        return function($object){};
    }

having investigated, I can see that the PopulateSearch class (which seems to be run via /dev/tasks/PopulateSearch and onAfterWrite of any DataObject which is being made searchable) contains the following conditional statement for each DataObject marked as being searchable:

if(method_exists($class, 'getSearchFilterByCallback')){
                $dos = $dos->filterByCallback($class::getSearchFilterByCallback());
}

Although I do appreciate your comments above the getSearchFilterByCallback() method do provide an example of a callback method, I had assumed that the default function in your example ( function($object){}; ) would have ben sufficient, but the lack of any return statement means that this example effectively returns false every time it is run.

This means that none of my DataObjects were being stored in the SearchableDataObjects database table (as getSearchFilterByCallback() was excluding them all) and therefore none were showing up in the search.

I would suggest making the example method contain return true; would be a logical addition and hopefully save others some time and not following the same path as I did. For example:

    /**
     * FilterByCallback function (optional)
     * eg. function($object){
     *  return ($object->StartDate > date('Y-m-d') || $object->isStillRecurring());
     * };
     * @return array
     */
    public static function getSearchFilterByCallback() {
        return function($object){return true;};
    }

Return 1 Page when Multiple DataObject ComeBack

I'm using the modules to search content blocks on my site, but it returns a seperate entry for each dataobject, I'd like to only return the page once if the word is found. Is this possible?

Possibility to search substrings / use wildcard

At the moment mysql only returns full words found.

In German language we have a lot of combined words, like "Audittermine" which is combined by "Audit" and "Termine"

It would be great if a search for "Audit" would also match "Audittermine", or search for singular "Termin" would also match "Termine", maybe configurable?

From a short research we'd need a wildcard in the query and switch to BOOLEAN MODE, see http://stackoverflow.com/a/9284693/4137738

SS 4.5 populate search issue

Edit
After adding implements Searchable to my dataobject, dev/build fails.
/Edit

After installation on SS4.5.1 I get the following error when I run the populate search task

Uncaught SilverStripe\ORM\Connect\DatabaseException: Couldn't run query: TRUNCATE TABLE SearchableDataObjects Table ... doesn't exist

Thanks in advance

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.