{"id":37261911,"url":"https://github.com/olegpro/bitrix-sphinx","last_synced_at":"2026-01-15T23:13:26.805Z","repository":{"id":49131562,"uuid":"92725016","full_name":"olegpro/bitrix-sphinx","owner":"olegpro","description":"Пакет добавляет в 1С-Битрикс возможность работать с индексами sphinx, через ORM D7","archived":false,"fork":false,"pushed_at":"2021-06-27T15:15:45.000Z","size":21,"stargazers_count":27,"open_issues_count":0,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-25T04:24:19.315Z","etag":null,"topics":["bitrix","orm-d7","sphinx"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olegpro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-29T09:23:56.000Z","updated_at":"2024-07-18T22:27:15.000Z","dependencies_parsed_at":"2022-09-22T14:25:42.114Z","dependency_job_id":null,"html_url":"https://github.com/olegpro/bitrix-sphinx","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/olegpro/bitrix-sphinx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olegpro%2Fbitrix-sphinx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olegpro%2Fbitrix-sphinx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olegpro%2Fbitrix-sphinx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olegpro%2Fbitrix-sphinx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olegpro","download_url":"https://codeload.github.com/olegpro/bitrix-sphinx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olegpro%2Fbitrix-sphinx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28419203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["bitrix","orm-d7","sphinx"],"created_at":"2026-01-15T23:13:26.235Z","updated_at":"2026-01-15T23:13:26.783Z","avatar_url":"https://github.com/olegpro.png","language":"PHP","readme":"# Olegpro\\\\BitrixSphinx\n\n[![Build Status](https://travis-ci.org/olegpro/bitrix-sphinx.svg)](https://travis-ci.org/olegpro/bitrix-sphinx)\n[![Latest Stable Version](https://poser.pugx.org/olegpro/bitrix-sphinx/v/stable)](https://packagist.org/packages/olegpro/bitrix-sphinx) \n[![Total Downloads](https://poser.pugx.org/olegpro/bitrix-sphinx/downloads)](https://packagist.org/packages/olegpro/bitrix-sphinx) \n[![License](https://poser.pugx.org/olegpro/bitrix-sphinx/license)](https://packagist.org/packages/olegpro/bitrix-sphinx)\n\nПакет добавляет в 1С-Битрикс возможность работать с индексами sphinx, через ORM D7, как с привычными сущностями (например \\Bitrix\\Iblock\\ElementTable или \\Bitrix\\Catalog\\PriceTable)\n\n# Настройка\n\nСоздаём класс ORM-сущность:\n\n```php\n\u003c?php\n\nuse Bitrix\\Main;\nuse Bitrix\\Main\\Localization\\Loc;\nuse Olegpro\\BitrixSphinx\\Entity\\SphinxDataManager;\nuse Olegpro\\BitrixSphinx\\Entity\\SphinxQuery;\n\nLoc::loadMessages(__FILE__);\n\nclass SampleTable extends SphinxDataManager\n{\n\n    /**\n     * Returns index sphinx name for entity.\n     *\n     * @return string\n     */\n    public static function getTableName()\n    {\n        return 'sample_index';\n    }\n\n    /**\n     * Returns sphinx-connection name for entity\n     *\n     * @return string\n     */\n    public static function getConnectionName()\n    {\n        return 'sphinx';\n    }\n\n    /**\n     * Creates and returns the Query object for the entity\n     *\n     * @return SphinxQuery\n     */\n    public static function query()\n    {\n        return new SphinxQuery(static::getEntity());\n    }\n\n    /**\n     * Returns entity map definition.\n     *\n     * @return array\n     */\n    public static function getMap()\n    {\n        return [\n            new Main\\Entity\\IntegerField('id', [\n                'primary' =\u003e true,\n            ]),\n            new Main\\Entity\\StringField('name'),\n            new Main\\Entity\\BooleanField('available', [\n                'values' =\u003e [0, 1],\n            ])\n        ];\n\n    }\n\n}\n\n```\n\nОписываем новое подключение в файле /bitrix/.settings.php в секцию connections:\n\n```php\n'connections' =\u003e\n    array(\n        'value' =\u003e\n            array(\n                'default' =\u003e\n                        array(\n                            // ...\n                        )\n                    ),\n                'sphinx' =\u003e\n                    array(\n                        'className' =\u003e '\\\\Olegpro\\\\BitrixSphinx\\\\DB\\\\SphinxConnection',\n                        'host' =\u003e '127.0.0.1:9306',\n                        'database' =\u003e '',\n                        'login' =\u003e '',\n                        'password' =\u003e '',\n                        'options' =\u003e 1,\n                    ),\n            ),\n        'readonly' =\u003e true,\n    ),\n```\n\n# Использование\n\n```php\n\u003c?php\n\nuse Bitrix\\Main\\Application;\nuse Bitrix\\Main\\Entity\\ExpressionFieldd;\n\nrequire($_SERVER['DOCUMENT_ROOT'] . '/bitrix/header.php');\n\nApplication::getConnection(SampleTable::getConnectionName())-\u003estartTracker(true);\n\n$iterator = SampleTable::getList([\n    'select' =\u003e [\n        '*',\n        new ExpressionField('weight', 'WEIGHT()', 'id'),\n    ],\n    'match' =\u003e 'книга',\n    'filter' =\u003e [\n        '=available' =\u003e 1,\n    ],\n    'limit' =\u003e 10,\n    'order' =\u003e [\n        'weight' =\u003e 'DESC',\n    ],\n    'option' =\u003e [\n        'max_matches' =\u003e 50000,\n    ],\n]);\n\necho '\u003cpre\u003e';print_r($iterator-\u003egetTrackerQuery()-\u003egetSql());echo '\u003c/pre\u003e';\n\necho '\u003cpre\u003e';print_r($iterator-\u003efetchAll());echo '\u003c/pre\u003e';\n\n```\n\n## С постраничной навигацией \n\n```php\n\u003c?php\n\nuse Bitrix\\Main\\Application;\nuse Bitrix\\Main\\Entity\\ExpressionFieldd;\nuse Bitrix\\Main\\UI\\PageNavigation;\n\nrequire($_SERVER['DOCUMENT_ROOT'] . '/bitrix/header.php');\n\nApplication::getConnection(SampleTable::getConnectionName())-\u003estartTracker(true);\n\n$nav = new PageNavigation('s');\n\n$nav-\u003eallowAllRecords(false)\n    -\u003esetPageSize(10)\n    -\u003einitFromUri();\n\n$iterator = SampleTable::getList([\n    'select' =\u003e [\n        '*',\n        new ExpressionField('weight', 'WEIGHT()', 'id'),\n    ],\n    'match' =\u003e 'книга',\n    'filter' =\u003e [\n        '=available' =\u003e 1,\n    ],\n    'count_total' =\u003e true,\n    'offset' =\u003e $nav-\u003egetOffset(),\n    'limit' =\u003e $nav-\u003egetLimit(),\n    'order' =\u003e [\n        'weight' =\u003e 'DESC',\n    ],\n    'option' =\u003e [\n        'max_matches' =\u003e 50000,\n    ],\n]);\n\n$nav-\u003esetRecordCount($iterator-\u003egetCount());\n\necho '\u003cpre\u003e';print_r($iterator-\u003egetTrackerQuery()-\u003egetSql());echo '\u003c/pre\u003e';\n\necho '\u003cpre\u003e';print_r($iterator-\u003efetchAll());echo '\u003c/pre\u003e';\n\n\n$APPLICATION-\u003eIncludeComponent(\n    \"bitrix:main.pagenavigation\",\n    \"\",\n    array(\n        \"NAV_OBJECT\" =\u003e $nav,\n        \"SEF_MODE\" =\u003e \"N\",\n    ),\n    false\n);\n\n```\n\n# Использование только с master-подключением\n\nМожно установить глобально для всего сайта, добавив в /bitrix/.settings.php\n\n```php\n'olegpro_bitrix_sphinx' =\u003e \n    array (\n        'value' =\u003e \n            array (\n              'use_connection_master_only' =\u003e true,\n            ),\n    'readonly' =\u003e false,\n),\n```\n\nМожно конкретно для каждого запроса передав use_connection_master_only = true:\n\n```php\n\n$iterator = SampleTable::getList([\n    'select' =\u003e [\n        '*',\n        new ExpressionField('weight', 'WEIGHT()', 'id'),\n    ],\n    'match' =\u003e 'книга',\n    'filter' =\u003e [\n        '=available' =\u003e 1,\n    ],\n    'limit' =\u003e 10,\n    'order' =\u003e [\n        'weight' =\u003e 'DESC',\n    ],\n    'option' =\u003e [\n        'max_matches' =\u003e 50000,\n    ],\n    'use_connection_master_only' =\u003e true,\n]);\n\n```\n\n# Установка пакета\n\nДобавить библиотеку в Composer:\n\n```\ncomposer require olegpro/bitrix-sphinx\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folegpro%2Fbitrix-sphinx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folegpro%2Fbitrix-sphinx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folegpro%2Fbitrix-sphinx/lists"}