GitHub PullRequestReviewCommentEvent at 2014-08-13 16:23:14
Repository: Sylius
Actor: agounaris
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/16186743","id":16186743,"diff_hunk":"@@ -0,0 +1,270 @@\n+<?php\n+\n+/*\n+ * This file is part of the Sylius package.\n+ *\n+ * (c) Paweł Jędrzejewski\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace Sylius\\Bundle\\SearchBundle\\Indexer;\n+\n+use Doctrine\\ORM\\EntityManager;\n+use FOS\\ElasticaBundle\\Transformer\\ModelToElasticaAutoTransformer;\n+use Sylius\\Bundle\\SearchBundle\\Entity\\SyliusSearchIndex;\n+\n+/**\n+ * Orm Indexer\n+ *\n+ * @author Argyrios Gounaris <agounaris@gmail.com>\n+ */\n+class OrmIndexer implements IndexerInterface\n+{\n+    /**\n+     * @var array\n+     */\n+    private $config;\n+\n+    /**\n+     * @var\n+     */\n+    private $em;\n+\n+    /**\n+     * @var\n+     */\n+    protected $transformer;\n+\n+    const SPACER = ' ';\n+\n+    /**\n+     * @param array                          $config\n+     * @param ModelToElasticaAutoTransformer $transformer\n+     */\n+    public function __construct(Array $config, ModelToElasticaAutoTransformer $transformer)\n+    {\n+        $this->config      = $config;\n+        $this->transformer = $transformer;\n+    }\n+\n+    /**\n+     * @param EntityManager $em\n+     */\n+    public function setEntityManager(EntityManager $em)\n+    {\n+        $this->em = $em;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function populate(EntityManager $em = null)\n+    {\n+        $this->setEntityManager($em);\n+\n+        echo 'Reseting index' . PHP_EOL;\n+\n+        $sql  = 'show index from sylius_search_index';","path":"src/Sylius/Bundle/SearchBundle/Indexer/OrmIndexer.php","position":69,"original_position":69,"commit_id":"a69307fd7d402777883b811d7dd1059662da91a7","original_commit_id":"a69307fd7d402777883b811d7dd1059662da91a7","user":{"login":"agounaris","id":1845809,"avatar_url":"https://avatars.githubusercontent.com/u/1845809?v=2","gravatar_id":"3d2798802cbecb526820ac150d9d1b0c","url":"https://api.github.com/users/agounaris","html_url":"https://github.com/agounaris","followers_url":"https://api.github.com/users/agounaris/followers","following_url":"https://api.github.com/users/agounaris/following{/other_user}","gists_url":"https://api.github.com/users/agounaris/gists{/gist_id}","starred_url":"https://api.github.com/users/agounaris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agounaris/subscriptions","organizations_url":"https://api.github.com/users/agounaris/orgs","repos_url":"https://api.github.com/users/agounaris/repos","events_url":"https://api.github.com/users/agounaris/events{/privacy}","received_events_url":"https://api.github.com/users/agounaris/received_events","type":"User","site_admin":false},"body":"I did some more tests to remind myself about this decision. \r\n\r\nSo the createNativeQuery produces the following\r\n```\r\n$rsm = new ResultSetMapping();\r\n        $query = $em->createNativeQuery('show index from sylius_search_index', $rsm);\r\n        $result = $query->getResult();\r\n\r\narray(0) {\r\n}\r\n```\r\n\r\nWhen raw PDO produces the..\r\n```\r\n$sql  = 'show index from sylius_search_index';\r\n$stmt = $this->em->getConnection()\r\n            ->prepare($sql);\r\n$stmt->execute();\r\n$res = $stmt->fetchAll(\\PDO::FETCH_COLUMN, 2);\r\n\r\narray(4) {\r\n  [0] =>\r\n  string(7) \"PRIMARY\"\r\n  [1] =>\r\n  string(18) \"item_id_entity_idx\"\r\n  [2] =>\r\n  string(18) \"item_id_entity_idx\"\r\n  [3] =>\r\n  string(19) \"fulltext_search_idx\"\r\n}\r\n```\r\n\r\nThis was an inconsistency that forced my to use pdo to get the result I had to, in order to determine the state of the index table.\r\n\r\nI'm also using pdo on OrmFinder because doctrine does not support directly MATCH AGAINST query, you need to write a wrapper or something to perform it and I think it doesn't worth the effort\r\n\r\n```php\r\n        $sql = 'select item_id, tags, entity from sylius_search_index WHERE MATCH(value) AGAINST (:searchterm)';\r\n```\r\n\r\nLet me know what you think.","created_at":"2014-08-13T16:23:14Z","updated_at":"2014-08-13T16:23:14Z","html_url":"https://github.com/Sylius/Sylius/pull/1784#discussion_r16186743","pull_request_url":"https://api.github.com/repos/Sylius/Sylius/pulls/1784","_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/16186743"},"html":{"href":"https://github.com/Sylius/Sylius/pull/1784#discussion_r16186743"},"pull_request":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/1784"}}},"pull_request":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/1784","id":19667960,"html_url":"https://github.com/Sylius/Sylius/pull/1784","diff_url":"https://github.com/Sylius/Sylius/pull/1784.diff","patch_url":"https://github.com/Sylius/Sylius/pull/1784.patch","issue_url":"https://api.github.com/repos/Sylius/Sylius/issues/1784","number":1784,"state":"open","title":"Sylius search","user":{"login":"agounaris","id":1845809,"avatar_url":"https://avatars.githubusercontent.com/u/1845809?v=2","gravatar_id":"3d2798802cbecb526820ac150d9d1b0c","url":"https://api.github.com/users/agounaris","html_url":"https://github.com/agounaris","followers_url":"https://api.github.com/users/agounaris/followers","following_url":"https://api.github.com/users/agounaris/following{/other_user}","gists_url":"https://api.github.com/users/agounaris/gists{/gist_id}","starred_url":"https://api.github.com/users/agounaris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agounaris/subscriptions","organizations_url":"https://api.github.com/users/agounaris/orgs","repos_url":"https://api.github.com/users/agounaris/repos","events_url":"https://api.github.com/users/agounaris/events{/privacy}","received_events_url":"https://api.github.com/users/agounaris/received_events","type":"User","site_admin":false},"body":"Hello Guys,\r\n\r\nThis is my initial pull request for the Sylius search feature as outlined on https://github.com/Sylius/Sylius/issues/1583\r\n\r\nWithin SearchBundle there is a README file with a few instructions on how to use the bundle. This explains the notion of the finder and how it can be used optionally with facets for different situations such as a front-end category page, the main search results page or through the backend interface. \r\n\r\nAt this time I have implemented support for small applications using ORM (mysql actually) and larger ones with ElasticSearch. It should be easy to add more engines in future.\r\n\r\nThere are a few TODO comments in the code mentioning our decisions and what can be changed in the future, but I'm hoping for some feedback and guidance first.\r\n\r\nVideos created for demo purposes:\r\nhttp://youtu.be/mACQeN1UNzQ\r\nhttp://youtu.be/XBfxdrlQyzM\r\n\r\nRegarding Behat tests there are 2 modes, one for mysql and one for elastic search. Keep that in mind when you want to run them.\r\n\r\n![screenshot 2014-08-12 15 20 58](https://cloud.githubusercontent.com/assets/1845809/3892445/61286522-2232-11e4-81dd-c9d4560270ec.png)\r\n\r\n![screenshot 2014-08-12 15 56 39](https://cloud.githubusercontent.com/assets/1845809/3892447/6421eb04-2232-11e4-8130-2b847fe6fecf.png)\r\n\r\n","created_at":"2014-08-12T15:13:54Z","updated_at":"2014-08-13T16:23:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e078b3017b66c2301989377168599eb10051e958","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Sylius/Sylius/pulls/1784/commits","review_comments_url":"https://api.github.com/repos/Sylius/Sylius/pulls/1784/comments","review_comment_url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Sylius/Sylius/issues/1784/comments","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/a69307fd7d402777883b811d7dd1059662da91a7","head":{"label":"agounaris:sylius-search","ref":"sylius-search","sha":"a69307fd7d402777883b811d7dd1059662da91a7","user":{"login":"agounaris","id":1845809,"avatar_url":"https://avatars.githubusercontent.com/u/1845809?v=2","gravatar_id":"3d2798802cbecb526820ac150d9d1b0c","url":"https://api.github.com/users/agounaris","html_url":"https://github.com/agounaris","followers_url":"https://api.github.com/users/agounaris/followers","following_url":"https://api.github.com/users/agounaris/following{/other_user}","gists_url":"https://api.github.com/users/agounaris/gists{/gist_id}","starred_url":"https://api.github.com/users/agounaris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agounaris/subscriptions","organizations_url":"https://api.github.com/users/agounaris/orgs","repos_url":"https://api.github.com/users/agounaris/repos","events_url":"https://api.github.com/users/agounaris/events{/privacy}","received_events_url":"https://api.github.com/users/agounaris/received_events","type":"User","site_admin":false},"repo":{"id":20296615,"name":"Sylius","full_name":"agounaris/Sylius","owner":{"login":"agounaris","id":1845809,"avatar_url":"https://avatars.githubusercontent.com/u/1845809?v=2","gravatar_id":"3d2798802cbecb526820ac150d9d1b0c","url":"https://api.github.com/users/agounaris","html_url":"https://github.com/agounaris","followers_url":"https://api.github.com/users/agounaris/followers","following_url":"https://api.github.com/users/agounaris/following{/other_user}","gists_url":"https://api.github.com/users/agounaris/gists{/gist_id}","starred_url":"https://api.github.com/users/agounaris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agounaris/subscriptions","organizations_url":"https://api.github.com/users/agounaris/orgs","repos_url":"https://api.github.com/users/agounaris/repos","events_url":"https://api.github.com/users/agounaris/events{/privacy}","received_events_url":"https://api.github.com/users/agounaris/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/agounaris/Sylius","description":"Modern e-commerce for PHP, based on the Symfony2 framework.","fork":true,"url":"https://api.github.com/repos/agounaris/Sylius","forks_url":"https://api.github.com/repos/agounaris/Sylius/forks","keys_url":"https://api.github.com/repos/agounaris/Sylius/keys{/key_id}","collaborators_url":"https://api.github.com/repos/agounaris/Sylius/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/agounaris/Sylius/teams","hooks_url":"https://api.github.com/repos/agounaris/Sylius/hooks","issue_events_url":"https://api.github.com/repos/agounaris/Sylius/issues/events{/number}","events_url":"https://api.github.com/repos/agounaris/Sylius/events","assignees_url":"https://api.github.com/repos/agounaris/Sylius/assignees{/user}","branches_url":"https://api.github.com/repos/agounaris/Sylius/branches{/branch}","tags_url":"https://api.github.com/repos/agounaris/Sylius/tags","blobs_url":"https://api.github.com/repos/agounaris/Sylius/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/agounaris/Sylius/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/agounaris/Sylius/git/refs{/sha}","trees_url":"https://api.github.com/repos/agounaris/Sylius/git/trees{/sha}","statuses_url":"https://api.github.com/repos/agounaris/Sylius/statuses/{sha}","languages_url":"https://api.github.com/repos/agounaris/Sylius/languages","stargazers_url":"https://api.github.com/repos/agounaris/Sylius/stargazers","contributors_url":"https://api.github.com/repos/agounaris/Sylius/contributors","subscribers_url":"https://api.github.com/repos/agounaris/Sylius/subscribers","subscription_url":"https://api.github.com/repos/agounaris/Sylius/subscription","commits_url":"https://api.github.com/repos/agounaris/Sylius/commits{/sha}","git_commits_url":"https://api.github.com/repos/agounaris/Sylius/git/commits{/sha}","comments_url":"https://api.github.com/repos/agounaris/Sylius/comments{/number}","issue_comment_url":"https://api.github.com/repos/agounaris/Sylius/issues/comments/{number}","contents_url":"https://api.github.com/repos/agounaris/Sylius/contents/{+path}","compare_url":"https://api.github.com/repos/agounaris/Sylius/compare/{base}...{head}","merges_url":"https://api.github.com/repos/agounaris/Sylius/merges","archive_url":"https://api.github.com/repos/agounaris/Sylius/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/agounaris/Sylius/downloads","issues_url":"https://api.github.com/repos/agounaris/Sylius/issues{/number}","pulls_url":"https://api.github.com/repos/agounaris/Sylius/pulls{/number}","milestones_url":"https://api.github.com/repos/agounaris/Sylius/milestones{/number}","notifications_url":"https://api.github.com/repos/agounaris/Sylius/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/agounaris/Sylius/labels{/name}","releases_url":"https://api.github.com/repos/agounaris/Sylius/releases{/id}","created_at":"2014-05-29T14:33:53Z","updated_at":"2014-08-11T16:36:23Z","pushed_at":"2014-08-12T15:06:25Z","git_url":"git://github.com/agounaris/Sylius.git","ssh_url":"git@github.com:agounaris/Sylius.git","clone_url":"https://github.com/agounaris/Sylius.git","svn_url":"https://github.com/agounaris/Sylius","homepage":"Sylius.org","size":13215,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Sylius:master","ref":"master","sha":"b273b294341ec42c0aba145e8be5dbc16d9591dd","user":{"login":"Sylius","id":719423,"avatar_url":"https://avatars.githubusercontent.com/u/719423?v=2","gravatar_id":"51710342957a82f3a2ed91d1d45f11dc","url":"https://api.github.com/users/Sylius","html_url":"https://github.com/Sylius","followers_url":"https://api.github.com/users/Sylius/followers","following_url":"https://api.github.com/users/Sylius/following{/other_user}","gists_url":"https://api.github.com/users/Sylius/gists{/gist_id}","starred_url":"https://api.github.com/users/Sylius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sylius/subscriptions","organizations_url":"https://api.github.com/users/Sylius/orgs","repos_url":"https://api.github.com/users/Sylius/repos","events_url":"https://api.github.com/users/Sylius/events{/privacy}","received_events_url":"https://api.github.com/users/Sylius/received_events","type":"Organization","site_admin":false},"repo":{"id":2717549,"name":"Sylius","full_name":"Sylius/Sylius","owner":{"login":"Sylius","id":719423,"avatar_url":"https://avatars.githubusercontent.com/u/719423?v=2","gravatar_id":"51710342957a82f3a2ed91d1d45f11dc","url":"https://api.github.com/users/Sylius","html_url":"https://github.com/Sylius","followers_url":"https://api.github.com/users/Sylius/followers","following_url":"https://api.github.com/users/Sylius/following{/other_user}","gists_url":"https://api.github.com/users/Sylius/gists{/gist_id}","starred_url":"https://api.github.com/users/Sylius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sylius/subscriptions","organizations_url":"https://api.github.com/users/Sylius/orgs","repos_url":"https://api.github.com/users/Sylius/repos","events_url":"https://api.github.com/users/Sylius/events{/privacy}","received_events_url":"https://api.github.com/users/Sylius/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Sylius/Sylius","description":"Modern e-commerce for PHP, based on the Symfony2 framework.","fork":false,"url":"https://api.github.com/repos/Sylius/Sylius","forks_url":"https://api.github.com/repos/Sylius/Sylius/forks","keys_url":"https://api.github.com/repos/Sylius/Sylius/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Sylius/Sylius/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Sylius/Sylius/teams","hooks_url":"https://api.github.com/repos/Sylius/Sylius/hooks","issue_events_url":"https://api.github.com/repos/Sylius/Sylius/issues/events{/number}","events_url":"https://api.github.com/repos/Sylius/Sylius/events","assignees_url":"https://api.github.com/repos/Sylius/Sylius/assignees{/user}","branches_url":"https://api.github.com/repos/Sylius/Sylius/branches{/branch}","tags_url":"https://api.github.com/repos/Sylius/Sylius/tags","blobs_url":"https://api.github.com/repos/Sylius/Sylius/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Sylius/Sylius/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Sylius/Sylius/git/refs{/sha}","trees_url":"https://api.github.com/repos/Sylius/Sylius/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/{sha}","languages_url":"https://api.github.com/repos/Sylius/Sylius/languages","stargazers_url":"https://api.github.com/repos/Sylius/Sylius/stargazers","contributors_url":"https://api.github.com/repos/Sylius/Sylius/contributors","subscribers_url":"https://api.github.com/repos/Sylius/Sylius/subscribers","subscription_url":"https://api.github.com/repos/Sylius/Sylius/subscription","commits_url":"https://api.github.com/repos/Sylius/Sylius/commits{/sha}","git_commits_url":"https://api.github.com/repos/Sylius/Sylius/git/commits{/sha}","comments_url":"https://api.github.com/repos/Sylius/Sylius/comments{/number}","issue_comment_url":"https://api.github.com/repos/Sylius/Sylius/issues/comments/{number}","contents_url":"https://api.github.com/repos/Sylius/Sylius/contents/{+path}","compare_url":"https://api.github.com/repos/Sylius/Sylius/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Sylius/Sylius/merges","archive_url":"https://api.github.com/repos/Sylius/Sylius/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Sylius/Sylius/downloads","issues_url":"https://api.github.com/repos/Sylius/Sylius/issues{/number}","pulls_url":"https://api.github.com/repos/Sylius/Sylius/pulls{/number}","milestones_url":"https://api.github.com/repos/Sylius/Sylius/milestones{/number}","notifications_url":"https://api.github.com/repos/Sylius/Sylius/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Sylius/Sylius/labels{/name}","releases_url":"https://api.github.com/repos/Sylius/Sylius/releases{/id}","created_at":"2011-11-05T22:05:52Z","updated_at":"2014-08-13T07:48:36Z","pushed_at":"2014-08-13T09:15:52Z","git_url":"git://github.com/Sylius/Sylius.git","ssh_url":"git@github.com:Sylius/Sylius.git","clone_url":"https://github.com/Sylius/Sylius.git","svn_url":"https://github.com/Sylius/Sylius","homepage":"Sylius.org","size":40248,"stargazers_count":1277,"watchers_count":1277,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":420,"mirror_url":null,"open_issues_count":349,"forks":420,"open_issues":349,"watchers":1277,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/1784"},"html":{"href":"https://github.com/Sylius/Sylius/pull/1784"},"issue":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/1784"},"comments":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/1784/comments"},"review_comments":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/1784/comments"},"review_comment":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/1784/commits"},"statuses":{"href":"https://api.github.com/repos/Sylius/Sylius/statuses/a69307fd7d402777883b811d7dd1059662da91a7"}}}}