{"id":28452597,"url":"https://github.com/livehelperchat/elasticsearch","last_synced_at":"2025-09-05T01:32:46.144Z","repository":{"id":46142284,"uuid":"98276038","full_name":"LiveHelperChat/elasticsearch","owner":"LiveHelperChat","description":"Elasticsearch integration for live helper chat to boost statistic generation.","archived":false,"fork":false,"pushed_at":"2025-09-03T11:28:00.000Z","size":1809,"stargazers_count":8,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-03T12:13:47.023Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LiveHelperChat.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-07-25T07:12:20.000Z","updated_at":"2025-09-03T11:28:03.000Z","dependencies_parsed_at":"2023-12-22T21:03:03.880Z","dependency_job_id":"a3588985-5dea-4d7f-b97e-546297feca9b","html_url":"https://github.com/LiveHelperChat/elasticsearch","commit_stats":{"total_commits":308,"total_committers":3,"mean_commits":"102.66666666666667","dds":0.01948051948051943,"last_synced_commit":"3708106032757180acd1f3493d0d563db849990f"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/LiveHelperChat/elasticsearch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiveHelperChat%2Felasticsearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiveHelperChat%2Felasticsearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiveHelperChat%2Felasticsearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiveHelperChat%2Felasticsearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiveHelperChat","download_url":"https://codeload.github.com/LiveHelperChat/elasticsearch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiveHelperChat%2Felasticsearch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273699554,"owners_count":25152281,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-06T18:11:59.787Z","updated_at":"2025-09-05T01:32:41.121Z","avatar_url":"https://github.com/LiveHelperChat.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Author\nRemigijus Kiminas, Live Helper Chat\n\n### ElasticSearch versions support\n - For ElasticSearch 7.x-8.x use master branch. If for 7.x you encounter some issues just use master-7.x branch.\n - For ElasticSearch 5-6 use master-5.x-6.x branch\n\n## Description\nThis plugin enables statistic generation using only Elastic Search. MySQL is not a good solution for statistic generation, but Elastic Search does great job on that.\n - Eliminates MySQL Queries in statistic generation\n - Allows to search withing messages with keyword\n - Allows to generate Online Operators/Active/Pending chat's chart\n \n![See image](https://livehelperchat.com/design/frontendnew/images/stats.png)\n\n## How it works?\n - After chat close event chat is indexed within cronjob.\n - Also there is cronjob which indexes existing data.\n\n## Future plans\n - Remove older chat's than 3 months and implement fallback if record is not found in MySQL. At the moment we just duplicate records.\n\n## Install\n\n1. Put elasticsearch folder in extensions folder.\n2. copy `extension/elasticsearch/settings.ini.default.php` to `extension/elasticsearch/settings.ini.php` and edit settings\n3. Activate extension in main settings `lhc_web/settings/settings.ini.php` file\n```\n'extensions' =\u003e \n      array (\n        'elasticsearch'\n      ),\n```\n4. Go to back office and clear cache.\n5. Go to Modules -\u003e Elastic Search\n6. Click create index and later update structure\n7. Execute doc/install.sql\n\n#### Indexing existing chats\n`php cron.php -s site_admin -e elasticsearch -c cron/index_chats`\n\n#### Indexing existing messages\n`php cron.php -s site_admin -e elasticsearch -c cron/index_msg`\n\n#### Indexing existing online sessions\n`php cron.php -s site_admin -e elasticsearch -c cron/index_os`\n\n#### Indexing existing participant data\n`php cron.php -s site_admin -e elasticsearch -c cron/index_participant`\n\n#### Setup automatic indexing [Required]\n`*/5 * * * * cd /home/www/lhc \u0026\u0026 php cron.php -s site_admin -e elasticsearch -c cron/cron \u003e log_index.txt /dev/null 2\u003e\u00261`\n\n#### Used to generate online operators/Active/Pending chat's chart [Optional]\n`* * * * * cd /home/www/lhc \u0026\u0026 php cron.php -s site_admin -e elasticsearch -c cron/cron_1m \u003e cron_1m.txt /dev/null 2\u003e\u00261`\n\n#### Used to remove duplicates every week [Optional]\n\nDuplicates can happen because elastic does not quarantine transactions. So this will make sure that there are no duplicates in ElasticSearch.\n\n`22 8 4 * * cd /home/www/lhc \u0026\u0026 php cron.php -s site_admin -e elasticsearch -c cron/remove_duplicates \u003e log_duplicates.txt /dev/null 2\u003e\u00261`\n\n#### Reindex recent chats [Optional]\n\nSometimes elastic search might miss chat's in it's index especially if it just hangs or some other bad things happens. This reindex last 16 hours chats to be sure they are presented in ElasticSearch.\n\n`36 */8 * * * cd /home/www/lhc \u0026\u0026 php cron.php -s site_admin -e elasticsearch -c cron/reindex_recent \u003e log_reindex_recent.txt /dev/null 2\u003e\u00261`\n\n### Online Visitors list using ElasticSearch\n\nSometimes operators run very heavy-duty filters on those lists, so it makes sense to delegate that payload to ElasticSearch\n\nRequirements\n\n* https://github.com/LiveHelperChat/lhc-php-resque\n\n#### Reindex recent online visitors\n\nThis will reindex all online visitors which time condition matches a configuration section. `How many days keep record of online visitors in Elastic Search from last visit.`\n\n`php cron.php -s site_admin -e elasticsearch -c cron/index_ov`\n\n#### Cleanup expired online visitors record\n\nDelete every 7 hours expired online visitor records\n\n`1 */6 * * * cd /home/www/lhc \u0026\u0026 php cron.php -s site_admin -e elasticsearch -c cron/index_ov_clean \u003e /dev/null 2\u003e\u00261`\n\n#### Using daily/monthly/yearly index\n\nI recommend if you are planning to have thousands of chats per day to use monthly or early index.\n\nIf you are running daily/monthly/yearly index you should be running this cronjob daily.\n\n`5 12 * * * cd /home/www/lhc \u0026\u0026 php cron.php -s site_admin -e elasticsearch -c cron/index_precreate`\n\nTo precreate/update index you can also run it like this one time\n\nCurrent year\n\n`/usr/bin/php cron.php -s site_admin -e elasticsearch -c cron/index_precreate -p yearly`\n\nManual year\n\n`/usr/bin/php cron.php -s site_admin -e elasticsearch -c cron/index_precreate -p 2022`\n\n#### Monitoring Elasticsearch\n\nTo receive notification about failure of Elasticsearch you can run this cronjob. It will automatically turn on/off Elasticsearch extension.\n\n`* * * * * cd /home/www/lhc \u0026\u0026 php cron.php -s site_admin -e elasticsearch -c cron/check_health`\n\n#### Sample for additional column from settings file\n\nIn relation to https://doc.livehelperchat.com/docs/bot/sentiment-analysis-per-message\n\nWhile setting config I suggest to set `'enabled' =\u003e false` and then run. So additional columns will be created and only then set `'enabled' =\u003e true` \n\n```shell\ncd /home/www/lhc \u0026\u0026 php cron.php -s site_admin -e elasticsearch -c cron/index_precreate\n```\n\nThis configuration defines two columns `sentiment_visitor` and `sentiment_visitor_value`. `sentiment_visitor_value_lt` does not have `type` and is not a field just a search attribute.\n\n```php\n'columns' =\u003e array(\n            'sentiment_visitor' =\u003e [\n                'enabled' =\u003e true,\n                'render' =\u003e array(\n                        'field' =\u003e 'sentiment_visitor',\n                        'type' =\u003e 'combobox',\n                        'trans' =\u003e erTranslationClassLhTranslation::getInstance()-\u003egetTranslation('abstract/proactivechatinvitation', 'Sentiment visitor'),\n                        'optional_value' =\u003e '',\n                        'required' =\u003e false,\n                        'direct_name' =\u003e true,\n                        'frontend' =\u003e 'name',\n                        'name_attr' =\u003e 'name',\n                        'source' =\u003e function() {\n                            $items = [];\n\n                            $item = new stdClass();\n                            $item-\u003eid = 'negative';\n                            $item-\u003ename = 'negative';\n                            $items[] = $item;\n\n                            $item = new stdClass();\n                            $item-\u003eid = 'positive';\n                            $item-\u003ename = 'positive';\n                            $items[] = $item;\n\n                            $item = new stdClass();\n                            $item-\u003eid = 'neutral';\n                            $item-\u003ename = 'neutral';\n                            $items[] = $item;\n\n                            return $items;\n                        },\n                        'hide_optional' =\u003e false,\n                        'params_call' =\u003e array(),\n                        'validation_definition' =\u003e new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')\n                ),\n                'filter_type' =\u003e 'filterstring',\n                'type' =\u003e 'keyword',\n                'field_search' =\u003e 'sentiment_visitor',\n                'content' =\u003e '{args.chat.chat_variables_array.sentiment_visitor}'\n            ],\n            'sentiment_visitor_value' =\u003e [\n                'enabled' =\u003e true,\n                'width' =\u003e 'col-1',\n                'render' =\u003e array(\n                    'field' =\u003e 'sentiment_visitor_value',\n                    'type' =\u003e 'text',\n                    'trans' =\u003e erTranslationClassLhTranslation::getInstance()-\u003egetTranslation('abstract/proactivechatinvitation', 'Greater than'),\n                    'required' =\u003e false,\n                    'direct_name' =\u003e true,\n                    'placeholder' =\u003e '0.5 for 50%',\n                    'frontend' =\u003e 'name',\n                    'name_attr' =\u003e 'name',\n                    'hide_optional' =\u003e false,\n                    'params_call' =\u003e array(),\n                    'validation_definition' =\u003e new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'float')\n                ),\n                'filter_type' =\u003e 'filterrangefloatgt',\n                'type' =\u003e 'float',\n                'field_search' =\u003e 'sentiment_visitor_value',\n                'content' =\u003e '{args.chat.chat_variables_array.sentiment_visitor_value}'\n            ],\n            'sentiment_visitor_value_lt' =\u003e [\n                'enabled' =\u003e true,\n                'width' =\u003e 'col-1',\n                'render' =\u003e array(\n                    'field' =\u003e 'sentiment_visitor_value_lt',\n                    'type' =\u003e 'text',\n                    'trans' =\u003e erTranslationClassLhTranslation::getInstance()-\u003egetTranslation('abstract/proactivechatinvitation', 'Less than'),\n                    'required' =\u003e false,\n                    'direct_name' =\u003e true,\n                    'placeholder' =\u003e '0.5 for 50%',\n                    'frontend' =\u003e 'name',\n                    'name_attr' =\u003e 'name',\n                    'hide_optional' =\u003e false,\n                    'params_call' =\u003e array(),\n                    'validation_definition' =\u003e new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'float')\n                ),\n                'field_search' =\u003e 'sentiment_visitor_value',\n                'filter_type' =\u003e 'filterrangefloatlt',\n            ],\n        ),\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivehelperchat%2Felasticsearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flivehelperchat%2Felasticsearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivehelperchat%2Felasticsearch/lists"}