whatwedo / searchbundle Goto Github PK
View Code? Open in Web Editor NEWFull text search on Doctrine entities without external dependencies
Home Page: https://whatwedo.github.io/SearchBundle/#/
License: MIT License
Full text search on Doctrine entities without external dependencies
Home Page: https://whatwedo.github.io/SearchBundle/#/
License: MIT License
Exception:
DriverException
An exception occurred while executing 'SELECT w0_.foreign_id AS foreign_id_0, MATCH(w0_.content) AGAINST (?) AS sclr_1 FROM whatwedo_search_index w0_ WHERE MATCH(w0_.content) AGAINST (?) > 0 OR w0_.content LIKE ? GROUP BY w0_.foreign_id ORDER BY sclr_1 DESC' with params ["test", "test", "%test%"]:
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'pm.w0_.content' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
Stacktrace:
in AbstractMySQLDriver.php line 106
--
at AbstractMySQLDriver->convertException('An exception occurred while executing \'SELECT w0_.foreign_id AS foreign_id_0, MATCH(w0_.content) AGAINST (?) AS sclr_1 FROM whatwedo_search_index w0_ WHERE MATCH(w0_.content) AGAINST (?) > 0 OR w0_.content LIKE ? GROUP BY w0_.foreign_id ORDER BY sclr_1 DESC\' with params ["test", "test", "%test%"]:SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column \'pm.w0_.content\' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by', object(PDOException))in DBALException.php line 166
at DBALException::wrapException(object(Driver), object(PDOException), 'An exception occurred while executing \'SELECT w0_.foreign_id AS foreign_id_0, MATCH(w0_.content) AGAINST (?) AS sclr_1 FROM whatwedo_search_index w0_ WHERE MATCH(w0_.content) AGAINST (?) > 0 OR w0_.content LIKE ? GROUP BY w0_.foreign_id ORDER BY sclr_1 DESC\' with params ["test", "test", "%test%"]:SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column \'pm.w0_.content\' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by')in DBALException.php line 146
at DBALException::driverExceptionDuringQuery(object(Driver), object(PDOException), 'SELECT w0_.foreign_id AS foreign_id_0, MATCH(w0_.content) AGAINST (?) AS sclr_1 FROM whatwedo_search_index w0_ WHERE MATCH(w0_.content) AGAINST (?) > 0 OR w0_.content LIKE ? GROUP BY w0_.foreign_id ORDER BY sclr_1 DESC', array('test', 'test', '%test%'))in Connection.php line 902
at Connection->executeQuery('SELECT w0_.foreign_id AS foreign_id_0, MATCH(w0_.content) AGAINST (?) AS sclr_1 FROM whatwedo_search_index w0_ WHERE MATCH(w0_.content) AGAINST (?) > 0 OR w0_.content LIKE ? GROUP BY w0_.foreign_id ORDER BY sclr_1 DESC', array('test', 'test', '%test%'),array(2, 2, 2), null)in SingleSelectExecutor.php line 50
at SingleSelectExecutor->execute(object(Connection), array('test', 'test', '%test%'), array(2, 2, 2))in Query.php line 334
at Query->_doExecute()in AbstractQuery.php line 967
at AbstractQuery->executeIgnoreQueryCache(null, 3)in AbstractQuery.php line 922
at AbstractQuery->execute(null, 3)in AbstractQuery.php line 750
at AbstractQuery->getScalarResult()in IndexRepository.php line 68
at IndexRepository->search('test')in SearchController.php line 38
I've tried to install SearchBundle on symfony 3.3.6 (also a clear fresh install) and on 3.1.10 but got the same error:
[Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException]
Circular reference detected for service "doctrine.dbal.default_connection", path: "doctrine.dbal.default_connection".
or
PHP Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "doctrine.dbal.default_connection", path: "doctrine.dbal.default_connection". in /home/dido/Documents/work/sk_futurespace/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php:515
Stack trace:
#0 /home/dido/Documents/work/sk_futurespace/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php(653): Symfony\Component\DependencyInjection\Dumper\PhpDumper->addServiceInlinedDefinitionsSetup('doctrine.dbal.d...', Array, true)
#1 /home/dido/Documents/work/sk_futurespace/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php(678): Symfony\Component\DependencyInjection\Dumper\PhpDumper->addService('doctrine.dbal.d...', Object(Symfony\Component\DependencyInjection\Definition))
#2 /home/dido/Documents/work/sk_futurespace/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDump in /home/dido/Documents/work/sk_futurespace/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php on line 515
And what I've done was just require, add bundle to AppKernel and on schema update got this error. It seems that You are injecting entity manager to IndexManager than injecting IndexManager into IndexListener which is a doctrine event listener. This might work on older versions of symfony (maybe?) but not on version 3.3.6 (nor 3.1.10). Could you please look into this issue and let me know if what am I doing wrong?
May I know if this project have a plan to support other types of primary key such as:
Symfony uuid:
* @ORM\Column(name="id", type="guid")
* @ORM\GeneratedValue(strategy="UUID")
&
Ramsey uuid-doctrine:
* @ORM\Column(type="uuid", unique=true)
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class=UuidGenerator::class)
If a value is inherited, populate the search only with the inherited model/value
exp.
class Identity {
// @Index()
public $name
}
class Customer extends Identity {
}
class Person extends Identity {
}
only Identity::name
should be populated in the search Table
in the Search results the inherited Models should be included
if the getQueryBuilder() is overwritten in the Repository the indexing fails
if the findAll() function filters the result. the PopulateCommand doesn't filter these entities.
public function findAll()
{
$queryBuilder = $this->createQueryBuilder('m');
$queryBuilder->where('m.isActive=true');
return $queryBuilder->getQuery()->getResult();
}
other possibility is to define a "findAllEntitiesToIndex()" method on the Repo. And called instead of the findAll(), if defined.
Manager/IndexManager.php (Line 107)
if (isset($this->config['entities'])) { foreach ($this->config['entities'] as $entityConfig) {
Allow using Attributes instead of Annotations.
eg:
#[Index]
private string $firstname;
Add functionality for Global searching:
Symfony\Bridge\Doctrine\RegistryInterface now has been deprecated and have to use Doctrine\Persistence\ManagerRegistry instead, can we have an update on this ?
See: http://symfony.com/blog/helping-prepare-for-symfony-4-bundle-support
in addition to run GC after every entity, do a gc after every 5'000 objects in addition.
Search for a query like s)
returns an error response
Should work nomally.
%
are currently working as wildcard. we should think about adding *
as a wildcard.
https://github.com/whatwedo/SearchBundle/blob/master/Resources/doc/index.md#use-the-bundle
$users $this->em->getRepository('whatwedoSearchBundle:Index')
should be $users $this->em->getRepository('AgencyUserBundle:User')
After upgrading a project to Symfony 5.1.10 an ServiceCircularReferenceException occours.
Circular reference detected for service "doctrine.orm.default_entity_manager", path: "doctrine.orm.default_entity_manager -> doctrine.orm.default_entity_manager".
removing the injectiion of the FormatterManager in IndexListener constructor resolves the issue.
Hello, in my project I'm using XML to declare a doctrine entity; How do i declare whatwedo\SearchBundle\Annotation\Index
in an XML file?
Hi,
I'm removing this bundle from an application and it left some not common footprint.
As you ship a Doctrine Migration to create the table and inject it automatically:
SearchBundle/src/DependencyInjection/whatwedoSearchExtension.php
Lines 41 to 46 in 733aefc
This is automatically added:
The thing is when removing this bundle from an existing application, this migration stays in the migration_versions table and this message is then displayed by Doctrine:
[WARNING] You have 1 previously executed migrations in the database that are not registered migrations.
There is no way for an application developer to clean this excepts manually:
DELETE FROM doctrine_migration_versions WHERE version = 'whatwedo\\SearchBundle\\Migrations\\Version20220602150539';
Maybe that should be documented, or maybe you had this issue before and there is a better way?
Cheers
preSearch Hook -> modify queryBuilder
postSearch Hook -> modify Id's
Add new Anntotation
SearchBundlde is not working properly in some cases.
I suspect the persist problem if short words are searched.
Search for "pure", minScore is 6
SELECT w0_.content, w0_.foreign_id AS foreign_id_0, MATCH(w0_.content) AGAINST ('pure') AS sclr_1 FROM whatwedo_search_index w0_
WHERE MATCH(w0_.content) AGAINST ('pure') > :minScore AND w0_.content LIKE '%pure%' AND w0_.model = 'Sensopro\\Entity\\Trainer' GROUP BY w0_.foreign_id ORDER BY sclr_1 DESC;
:minScore = 6
Result with minScore = 0
content | foreign_id | sclr_1 |
---|---|---|
'Pure 1 rechts LAN' | '2' | '4.997587203979492' |
'Pure 2 links WLAN' | '3' | '4.997587203979492' |
'purepurepure pure asdflaöd asdffiapweosd, afss assödkfaweirasssd fasdflaksdfasdf' | '13' | '4.997587203979492' |
'VK18134, Boutique 98 by pure senses' | '166' | '4.997587203979492' |
Search for "purepurepure", minScore is 18
SELECT w0_.content, w0_.foreign_id AS foreign_id_0, MATCH(w0_.content) AGAINST ('purepurepure') AS sclr_1 FROM whatwedo_search_index w0_
WHERE MATCH(w0_.content) AGAINST ('purepurepure') > :minScore AND w0_.content LIKE '%purepurepure%' AND w0_.model = 'Sensopro\\Entity\\Trainer' GROUP BY w0_.foreign_id ORDER BY sclr_1 DESC;
:minScore = 18
Result with minScore = 0
content | foreign_id | sclr_1 |
---|---|---|
'purepurepure pure asdflaöd asdffiapweosd, afss assödkfaweirasssd fasdflaksdfasdf' | '13' | '8.051908493041992' |
problem is located in the IndexRepository.php
->where("MATCH_AGAINST(i.content, :query) > :minScore")
->setParameter('minScore', round(strlen($query) * 1.5))
reducing the minScore factor solves the Problem, but can be still wrong,
in my opinion the minScore "where" should be removed.
in some cases, a list of archived entities is shown. or some other type of filtered list.
the search does not consider this filter.
Allow to filter the search results by a given filter.
Hi!,
I've installed this bundle; no problem what so ever. Also indexing is good, migrated properly.
But when i try to search, the results are always empty. I've debugged the code, and it seems that :minscore
in the QueryBuilder is not working properly. For example, in the whatwedo_search_index
table there is a row with content
'home'.
When searching on 'home' using the IndexRepository, zero results.
public function indexAction()
{
$results = $this->searchRepository->search('home', Page::class);
dd($results);
}
When commenting the minscore in the query builder, I do get the result. The minScore
for home is 6 (strlen('home') * 1.5). But the minscore
of the actual result is 5.5.
Any idea? Using MySQL 5.7 here.
Create an interface to get a queryBuilder for the searchables entities
interface PopulateSearchQueryBuilderInterface {
public funtion getPopulateSearchQueryBuilder(): QueryBuilder;
}
When I try to install the bundle, I got the next message in cache:clear script:
Cannot autowire service "whatwedo\SearchBundle\Manager\IndexManager": argument "$doctrine" of method "__construct()" references interface "Symfony\Bridge\Doctrine\RegistryInterface" but no such service exists. Try changing the type-hint to "Doctrine\Persistence\ManagerRegistry" instead.
I see a pull request making the change necessary to fix this issue, is going to be merged?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.