Compare commits

...

5 Commits

Author SHA1 Message Date
Thomas MONCHICOURT c1dc8f3fce Feat : edge-ngram 2017-06-12 14:06:14 +02:00
Thomas MONCHICOURT cf3079a418 Merge branch 'develop' into feat/talent_reseach
# Conflicts:
#	www/src/AppBundle/Controller/TalentController.php
2017-06-12 10:37:52 +02:00
Thomas MONCHICOURT dee5592da0 Feat : Image talent par default pour le talent #5008 @0h15 2017-05-18 14:59:33 +02:00
Thomas MONCHICOURT f0afc00dd0 Feat : modification du elastic pour les ads 2017-05-18 14:34:16 +02:00
Thomas MONCHICOURT ec7e067ff3 Feat : rechercher les talents #5008 @2h30 2017-05-18 11:56:01 +02:00
11 changed files with 220 additions and 16 deletions
@@ -10,8 +10,7 @@
<div class="valign">
<p><a href="#">Je suis une<br/><span>entreprise de talents</span>.</a></p>
<p>
{#<a href="{{ path('talent_search_result') }}" class="btn btn-white">Je recherche un#}
{#talent</a> #}
<a href="{{ path('talent_search_result') }}" class="btn btn-white">Je recherche un talent</a>
<a href="{{ path('company_ad_create') }}" class="btn btn-white">Je dépose
une annonce</a></p>
</div>
@@ -0,0 +1,22 @@
<div id="search">
<div class="row">
<div class="col s12 m3 l3 center-align">
<h5 class="white-text">Rechercher un talent</h5>
</div>
<div class="col s12 m6 l6">
{{ form_start(searchform,{action: path('talent_search_result'), method:'post'}) }}
<div class="row">
<div class="input-field col s10">
<p>{{ form_row(searchform.talent) }}</p>
<input id="search__token" name="search[_token]" value="{{ csrf_token("intention") }}" type="hidden">
</div>
<div class="input-field col s2">
<button class="btn btn-form waves-effect waves-light" type="submit" name="action">Ok</button>
</div>
</div>
{{ form_end(searchform) }}
</div>
<div class="col s12 m3 l3 center-align advanced-search">
</div>
</div>
</div>
@@ -19,6 +19,10 @@
alt="{{ user.firstname }} {{ user.lastname }}"/>
{% endif %}
<span class="playerbtn"></span>
{% else %}
<img class="thumbnail_list responsive-img"
src="{{ asset('/img/portrait-default.png')}}"
alt="{{ user.firstname }} {{ user.lastname }}"/>
{% endif %}
</a>
</div>
@@ -2,6 +2,7 @@
{% block content %}
{{ render(controller('AppBundle:Talent:talentSearchRender',{ 'type': 'lite' })) }}
<div id="wrapper">
<div class="row">
<div class="col s12 m12">
@@ -15,6 +15,10 @@
<div class="col s4 m4 l2 detail-item-logo col-padding-right">
{% if user.photo %}
<img class="responsive-img" src="{{ user.webPath | imagine_filter('profile_thumb') }}">
{% else %}
<img class="responsive-img"
src="{{ asset('/img/portrait-default.png') }}"
alt="{{ user.firstname }} {{ user.lastname }}"/>
{% endif %}
</div>
<div class="col s8 m8 l10 detail-item-titre">
+70 -7
View File
@@ -7,13 +7,17 @@ fos_elastica:
index:
analysis:
analyzer:
ad_fr_analyzer:
ad_fr_analyzer_search:
type: custom
tokenizer: standard
tokenizer: mynGram
filter: [asciifolding, lowercase, snowball_fr, stopwords_fr, ouhouhahah_fr, ngram_filter]
ad_fr_analyzer_index:
type: custom
tokenizer: mynGram
filter: [asciifolding, lowercase, snowball_fr, stopwords_fr, ouhouhahah_fr]
ad_fr_analyzer_lite:
type: custom
tokenizer: standard
tokenizer: mynGram
filter: [asciifolding, lowercase, ouhouhahah_fr]
filter:
stopwords_fr:
@@ -26,27 +30,82 @@ fos_elastica:
snowball_fr:
type: snowball
language: French
ngram_filter:
type: edge_ngram
min_gram: 3
max_gram: 10
tokenizer:
mynGram:
type: edge_ngram
min_gram: 3
max_gram: 10
token_chars: [letter,digit]
types:
adfr:
mappings:
title:
type: text
# boost: 3
analyzer: ad_fr_analyzer
search_analyzer: ad_fr_analyzer_search
analyzer: ad_fr_analyzer_index
location:
type: geo_point
property_path: getGeoPoint
publicTag: { analyzer: ad_fr_analyzer }
publicTag:
search_analyzer: ad_fr_analyzer_search
analyzer: ad_fr_analyzer_index
boost: 20
type: text
company:
type: object
properties:
brandname: { analyzer: ad_fr_analyzer_lite }
brandname:
search_analyzer: ad_fr_analyzer_search
analyzer: ad_fr_analyzer_index
type: text
persistence:
driver: orm
model: AppBundle\Entity\Ad
provider: ~
finder: ~
talents:
settings:
index:
analysis:
analyzer:
talent_fr_analyzer_search:
type: custom
tokenizer: mynGram
filter: [asciifolding, lowercase, snowball_fr, stopwords_fr, ouhouhahah_fr, ngram_filter]
talent_fr_analyzer_index:
type: custom
tokenizer: mynGram
filter: [asciifolding, lowercase, snowball_fr, stopwords_fr, ouhouhahah_fr, ngram_filter]
talent_fr_analyzer_lite:
type: custom
tokenizer: mynGram
filter: [asciifolding, lowercase, ouhouhahah_fr, ngram_filter]
filter:
stopwords_fr:
type: stop
stopwords: [_french_]
ignore_case: true
ouhouhahah_fr:
type: elision
articles: [l, m, t, qu, n, s, j, d]
snowball_fr:
type: snowball
language: French
ngram_filter:
type: edge_ngram
min_gram: 3
max_gram: 10
tokenizer:
mynGram:
type: edge_ngram
min_gram: 3
max_gram: 10
token_chars: [letter,digit]
types:
talentfr:
indexable_callback: 'isIndexableTalent'
@@ -56,7 +115,11 @@ fos_elastica:
company:
type: object
properties:
publicTag: ~
publicTag:
search_analyzer: talent_fr_analyzer_search
analyzer: talent_fr_analyzer_index
boost: 20
type: text
persistence:
driver: orm
model: AppBundle\Entity\User
+4
View File
@@ -22,6 +22,10 @@ services:
app.ad_searcher:
class: AppBundle\Utils\Services\AdSearcher
arguments: ['@fos_elastica.finder.ads.adfr']
app.talent_searcher:
class: AppBundle\Utils\Services\TalentSearcher
arguments: ['@fos_elastica.finder.talents.talentfr']
# Twig Extensions
twig.country_extension:
@@ -8,6 +8,7 @@ use AppBundle\Entity\Message;
use AppBundle\Form\MyAccountType;
use AppBundle\Form\TalentProfileType;
use AppBundle\Form\ContactTalentType;
use AppBundle\Form\TalentSearchType;
use Edeclic\PrestashopBridgeBundle\Event\PrestashopBridgeEvents;
use Edeclic\PrestashopBridgeBundle\Event\UserEvent;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
@@ -135,18 +136,52 @@ class TalentController extends Controller
*/
public function talentSearchResultAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$talents = $em->getRepository('AppBundle:Company')->findByType('TALENT');
$form = $this->createForm(TalentSearchType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
if(is_null($data['talent'])){
return $this->redirectToRoute('homepage');
}
$talentSearcher = $this->get('app.talent_searcher');
$talents = $talentSearcher->process($data);
$mediaManager = $this->get('media_manager');
foreach ($talents as $t) {
$message = $mediaManager->getThumbnails($t);
$mediaManager = $this->get('media_manager');
$companiesTalents = array();
foreach($talents as $talent){
if($talent->getCompany()->getPresentationVideo()){
$message = $mediaManager->getThumbnails($talent);
}
$companiesTalents[] = $talent->getCompany();
}
return $this->render('talent/talent_search_result.html.twig', [
'talents' => $companiesTalents,
]);
} else {
$em = $this->getDoctrine()->getManager();
$talents = $em->getRepository('AppBundle:Company')->findByType('TALENT');
$mediaManager = $this->get('media_manager');
foreach ($talents as $talent) {
if($talent->getPresentationVideo()){
$message = $mediaManager->getThumbnails($talent);
}
}
}
return $this->render('talent/talent_search_result.html.twig', [
'talents' => $talents,
]);
}
public function talentSearchRenderAction($type = 'lite')
{
$form = $this->createForm(TalentSearchType::class);
return $this->render('default/search_bar_talent.html.twig', array(
'searchform' => $form->createView(),
));
}
@@ -0,0 +1,24 @@
<?php
// src/AppBundle/Form/TaskType.php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
class TalentSearchType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('talent', TextType::class, array(
'label' => false,
'required' => true,
'attr' => array(
'placeholder' => 'Le talent de mes rêves',
)
));
}
}
@@ -48,7 +48,7 @@ class AdSearcher
$fieldQuery = new \Elastica\Query\MultiMatch();
$fieldQuery->setQuery($data['job']);
$fieldQuery->setFields(['title', 'publicTag', 'brandname']);
$fieldQuery->setFields(['title', 'publicTag', 'company.brandname']);
$boolQuery->addMust($fieldQuery);
@@ -0,0 +1,48 @@
<?php
namespace AppBundle\Utils\Services;
class TalentSearcher
{
protected $finder;
/**
* AdSearcher constructor.
* @param $finder
*/
public function __construct($finder)
{
$this->finder = $finder;
}
public function process($data, $param = 'lite')
{
if ($param == 'lite') {
$ads = $this->searchLite($data);
}
return $ads;
}
/**
* @param $data
* @return mixed
*/
public function searchLite($data)
{
$query = new \Elastica\Query();
$boolQuery = new \Elastica\Query\BoolQuery();
$fieldQuery = new \Elastica\Query\MultiMatch();
$fieldQuery->setQuery($data['talent']);
$fieldQuery->setFields(['firstname', 'lastname','company.publicTag']);
$boolQuery->addMust($fieldQuery);
$query->setQuery($boolQuery);
$result = $this->finder->find($query);
$ads = $result;
return $ads;
}
}