123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace App\Services\Elasticsearch\Erp;
- use App\Foundation\ElasticsearchClient;
- class BuyerService
- {
- /**
- * @var ElasticsearchClient
- */
- private $client;
- /**
- * @param ElasticsearchClient $client
- */
- public function __construct(ElasticsearchClient $client)
- {
- $this->client = $client;
- }
- public function getQueryAll($where)
- {
- $query = "
- SELECT * FROM erp_buyer
- WHERE $where
- ";
- return $this->executeSql($query);
- }
- public function executeSql($query)
- {
- return $this->client->client()->sql()->query([
- 'body' => [ 'query' => $query ]
- ])['rows'];
- }
- public function getQueryByKeyword($keyword)
- {
- return "SELECT serial_number
- FROM taling___products_product___v1
- WHERE
- (
- MATCH(name_nori, '$keyword') OR MATCH(name_jamo, '$keyword') OR MATCH(name_chosung, '$keyword')
- OR
- MATCH(display_name_nori, '$keyword') OR MATCH(display_name_jamo, '$keyword') OR MATCH(display_name_chosung, '$keyword')
- OR
- MATCH(description_nori, '$keyword') OR MATCH(description_jamo, '$keyword') OR MATCH(description_chosung, '$keyword')
- OR
- MATCH(market_name_nori, '$keyword') OR MATCH(market_name_jamo, '$keyword') OR MATCH(market_name_chosung, '$keyword')
- OR
- MATCH(category_name_nori, '$keyword') OR MATCH(category_name_jamo, '$keyword') OR MATCH(category_name_chosung, '$keyword')
- )
- ORDER BY score() DESC";
- }
- }
|