Loading module/Oscar/src/Oscar/Service/OrganizationService.php +12 −5 Changes for module/Oscar/src/Oscar/Service/OrganizationService.php: 12 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -276,10 +276,8 @@ class OrganizationService implements ServiceLocatorAwareInterface, EntityManager 'searchStrict' => strtolower($search), ] ); } } } if (isset($filter['type']) && $filter['type']){ Loading Loading @@ -318,6 +316,17 @@ class OrganizationService implements ServiceLocatorAwareInterface, EntityManager ->setParameter('ids', $ids); } if( count($ids) ){ $case = '(CASE '; $i = 0; foreach ($ids as $id) { $case .= sprintf('WHEN o.id = \'%s\' THEN %s ', $id, $i++); } $case .= " ELSE $id END) AS HIDDEN ORD"; $qb->addSelect($case); $qb->orderBy("ORD", 'ASC'); } return new UnicaenDoctrinePaginator($qb, $page); } Loading Loading @@ -350,9 +359,7 @@ class OrganizationService implements ServiceLocatorAwareInterface, EntityManager { $queryBuilder = $this->getEntityManager()->createQueryBuilder(); $queryBuilder->select('o') ->from(Organization::class, 'o') ->orderBy('o.shortName') ->addOrderBy('o.fullName'); ->from(Organization::class, 'o'); return $queryBuilder; } Loading module/Oscar/src/Oscar/Strategy/Search/OrganizationElasticSearch.php +77 −61 Changes for module/Oscar/src/Oscar/Strategy/Search/OrganizationElasticSearch.php: 77 added lines, 61 removed lines. Original line number Diff line number Diff line Loading @@ -65,30 +65,7 @@ class OrganizationElasticSearch implements OrganizationSearchStrategy return $this->elasticSearchClient; } public function search($search) { $params = [ 'index' => $this->getIndex(), 'type' => $this->getType(), 'body' => [ 'size' => 10000, 'query' => [ 'query_string' => [ 'query' => $search ] ] ] ]; $response = $this->getClient()->search($params); $ids = []; if ($response && $response['hits'] && $response['hits']['total'] > 0) { foreach ($response['hits']['hits'] as $hit) { $ids[] = $hit["_id"]; } } return $ids; } public function add(Organization $organization) { Loading Loading @@ -118,46 +95,9 @@ class OrganizationElasticSearch implements OrganizationSearchStrategy $this->resetIndex(); $repport->addnotice("Index réinitialisé"); /******** CONFIGURATION DU MAPPING $params = [ 'index' => $this->getIndex(), 'type' => $this->getType(), 'body' => [ 'my_type2' => [ '_source' => [ 'enabled' => true ], 'properties' => [ 'first_name' => [ 'type' => 'keyword', 'analyzer' => 'standard' ], 'age' => [ 'type' => 'integer' ] ] ] ] ]; * 'id' => $organization->getId(), 'code' => $organization->getCode(), 'shortname' => $organization->getShortName(), 'fullname' => $organization->getFullName(), 'email' => $organization->getEmail(), 'city' => $organization->getCity(), 'country' => $organization->getCountry(), 'zipcode' => $organization->getZipCode(), // 'address1' => $organization->getStreet1(), // 'address2' => $organization->getStreet2(), // 'address3' => $organization->getStreet3(), 'siret' => $organization->getSiret(), 'country' => $organization->getCountry(), 'persons' => $persons, 'activities' => $activities, 'connectors' => $connectors $response = $this->getClient()->indices()->putMapping($params); /****/ Loading Loading @@ -189,6 +129,56 @@ class OrganizationElasticSearch implements OrganizationSearchStrategy if (!empty($params['body'])) { $this->getClient()->bulk($params); } // 'id' => $organization->getId(), // 'code' => $organization->getCode(), // 'shortname' => $organization->getShortName(), // 'fullname' => $organization->getFullName(), // 'email' => $organization->getEmail(), // 'city' => $organization->getCity(), // 'country' => $organization->getCountry(), // 'zipcode' => $organization->getZipCode(), // // 'address1' => $organization->getStreet1(), // // 'address2' => $organization->getStreet2(), // // 'address3' => $organization->getStreet3(), // 'siret' => $organization->getSiret(), // 'country' => $organization->getCountry(), // 'persons' => $persons, // 'activities' => $activities, // 'connectors' => $connectors /******** CONFIGURATION DU MAPPING ***/ $params = [ 'index' => $this->getIndex(), 'type' => $this->getType(), 'body' => [ $this->getType() => [ '_source' => [ 'enabled' => true ], 'properties' => [ 'code' => [ 'type' => 'text' ], 'shortname' => [ 'type' => 'text', 'boost' => 5 ], 'fullname' => [ 'type' => 'text', 'boost' => 5 ], 'email' => [ 'type' => 'text' ], ] ] ] ]; $response = $this->getClient()->indices()->putMapping($params); return $repport; } Loading Loading @@ -243,6 +233,32 @@ class OrganizationElasticSearch implements OrganizationSearchStrategy ]; } public function search($search) { $params = [ 'index' => $this->getIndex(), 'type' => $this->getType(), 'body' => [ 'size' => 10000, 'query' => [ 'query_string' => [ 'fields' => ['code^5', 'shortname^5', 'fullname^5', 'email', 'city', 'siret', 'country', 'connectors', 'zipcode', 'persons^3', 'activities'], 'query' => $search, ] ] ] ]; $response = $this->getClient()->search($params); $ids = []; if ($response && $response['hits'] && $response['hits']['total'] > 0) { foreach ($response['hits']['hits'] as $hit) { $ids[] = $hit["_id"]; } } return $ids; } public function remove($id) { $parms = [ Loading Loading
module/Oscar/src/Oscar/Service/OrganizationService.php +12 −5 Changes for module/Oscar/src/Oscar/Service/OrganizationService.php: 12 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -276,10 +276,8 @@ class OrganizationService implements ServiceLocatorAwareInterface, EntityManager 'searchStrict' => strtolower($search), ] ); } } } if (isset($filter['type']) && $filter['type']){ Loading Loading @@ -318,6 +316,17 @@ class OrganizationService implements ServiceLocatorAwareInterface, EntityManager ->setParameter('ids', $ids); } if( count($ids) ){ $case = '(CASE '; $i = 0; foreach ($ids as $id) { $case .= sprintf('WHEN o.id = \'%s\' THEN %s ', $id, $i++); } $case .= " ELSE $id END) AS HIDDEN ORD"; $qb->addSelect($case); $qb->orderBy("ORD", 'ASC'); } return new UnicaenDoctrinePaginator($qb, $page); } Loading Loading @@ -350,9 +359,7 @@ class OrganizationService implements ServiceLocatorAwareInterface, EntityManager { $queryBuilder = $this->getEntityManager()->createQueryBuilder(); $queryBuilder->select('o') ->from(Organization::class, 'o') ->orderBy('o.shortName') ->addOrderBy('o.fullName'); ->from(Organization::class, 'o'); return $queryBuilder; } Loading
module/Oscar/src/Oscar/Strategy/Search/OrganizationElasticSearch.php +77 −61 Changes for module/Oscar/src/Oscar/Strategy/Search/OrganizationElasticSearch.php: 77 added lines, 61 removed lines. Original line number Diff line number Diff line Loading @@ -65,30 +65,7 @@ class OrganizationElasticSearch implements OrganizationSearchStrategy return $this->elasticSearchClient; } public function search($search) { $params = [ 'index' => $this->getIndex(), 'type' => $this->getType(), 'body' => [ 'size' => 10000, 'query' => [ 'query_string' => [ 'query' => $search ] ] ] ]; $response = $this->getClient()->search($params); $ids = []; if ($response && $response['hits'] && $response['hits']['total'] > 0) { foreach ($response['hits']['hits'] as $hit) { $ids[] = $hit["_id"]; } } return $ids; } public function add(Organization $organization) { Loading Loading @@ -118,46 +95,9 @@ class OrganizationElasticSearch implements OrganizationSearchStrategy $this->resetIndex(); $repport->addnotice("Index réinitialisé"); /******** CONFIGURATION DU MAPPING $params = [ 'index' => $this->getIndex(), 'type' => $this->getType(), 'body' => [ 'my_type2' => [ '_source' => [ 'enabled' => true ], 'properties' => [ 'first_name' => [ 'type' => 'keyword', 'analyzer' => 'standard' ], 'age' => [ 'type' => 'integer' ] ] ] ] ]; * 'id' => $organization->getId(), 'code' => $organization->getCode(), 'shortname' => $organization->getShortName(), 'fullname' => $organization->getFullName(), 'email' => $organization->getEmail(), 'city' => $organization->getCity(), 'country' => $organization->getCountry(), 'zipcode' => $organization->getZipCode(), // 'address1' => $organization->getStreet1(), // 'address2' => $organization->getStreet2(), // 'address3' => $organization->getStreet3(), 'siret' => $organization->getSiret(), 'country' => $organization->getCountry(), 'persons' => $persons, 'activities' => $activities, 'connectors' => $connectors $response = $this->getClient()->indices()->putMapping($params); /****/ Loading Loading @@ -189,6 +129,56 @@ class OrganizationElasticSearch implements OrganizationSearchStrategy if (!empty($params['body'])) { $this->getClient()->bulk($params); } // 'id' => $organization->getId(), // 'code' => $organization->getCode(), // 'shortname' => $organization->getShortName(), // 'fullname' => $organization->getFullName(), // 'email' => $organization->getEmail(), // 'city' => $organization->getCity(), // 'country' => $organization->getCountry(), // 'zipcode' => $organization->getZipCode(), // // 'address1' => $organization->getStreet1(), // // 'address2' => $organization->getStreet2(), // // 'address3' => $organization->getStreet3(), // 'siret' => $organization->getSiret(), // 'country' => $organization->getCountry(), // 'persons' => $persons, // 'activities' => $activities, // 'connectors' => $connectors /******** CONFIGURATION DU MAPPING ***/ $params = [ 'index' => $this->getIndex(), 'type' => $this->getType(), 'body' => [ $this->getType() => [ '_source' => [ 'enabled' => true ], 'properties' => [ 'code' => [ 'type' => 'text' ], 'shortname' => [ 'type' => 'text', 'boost' => 5 ], 'fullname' => [ 'type' => 'text', 'boost' => 5 ], 'email' => [ 'type' => 'text' ], ] ] ] ]; $response = $this->getClient()->indices()->putMapping($params); return $repport; } Loading Loading @@ -243,6 +233,32 @@ class OrganizationElasticSearch implements OrganizationSearchStrategy ]; } public function search($search) { $params = [ 'index' => $this->getIndex(), 'type' => $this->getType(), 'body' => [ 'size' => 10000, 'query' => [ 'query_string' => [ 'fields' => ['code^5', 'shortname^5', 'fullname^5', 'email', 'city', 'siret', 'country', 'connectors', 'zipcode', 'persons^3', 'activities'], 'query' => $search, ] ] ] ]; $response = $this->getClient()->search($params); $ids = []; if ($response && $response['hits'] && $response['hits']['total'] > 0) { foreach ($response['hits']['hits'] as $hit) { $ids[] = $hit["_id"]; } } return $ids; } public function remove($id) { $parms = [ Loading