Skip to content

Commit

Permalink
updated mapping for elastic index
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes committed Aug 19, 2016
1 parent a8244d2 commit e3447d3
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 13 deletions.
5 changes: 3 additions & 2 deletions Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use ONGR\ElasticsearchBundle\Service\Manager;
use ONGR\ElasticsearchDSL\Query\FuzzyQuery;
use ONGR\ElasticsearchDSL\Query\TermQuery;
use ONGR\ElasticsearchDSL\Query\WildcardQuery;
use ONGR\ElasticsearchDSL\Sort\FieldSort;
use Sulu\Bundle\ArticleBundle\Document\ArticleOngrDocument;
use Sulu\Bundle\ArticleBundle\Document\Form\ArticleDocumentType;
Expand Down Expand Up @@ -83,9 +84,9 @@ public function cgetAction(Request $request)
$repository = $manager->getRepository(ArticleOngrDocument::class);
$search = $repository->createSearch();

if (null !== ($searchPattern = $restHelper->getSearchPattern())) {
if (!empty($searchPattern = $restHelper->getSearchPattern())) {
foreach ($restHelper->getSearchFields() as $searchField) {
$search->addQuery(new FuzzyQuery($searchField, $searchPattern));
$search->addQuery(new WildcardQuery($searchField, '*' . $searchPattern . '*'));
}
}

Expand Down
40 changes: 36 additions & 4 deletions Document/ArticleOngrDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,30 @@ class ArticleOngrDocument
/**
* @var string
*
* @Property(type="string")
* @Property(
* type="string",
* options={
* "fields"={
* "raw"={"type"="string", "index"="not_analyzed"},
* "value"={"type"="string"}
* }
* }
* )
*/
protected $title;

/**
* @var string
*
* @Property(type="string")
* @Property(
* type="string",
* options={
* "fields"={
* "raw"={"type"="string", "index"="not_analyzed"},
* "value"={"type"="string"}
* }
* }
* )
*/
protected $routePath;

Expand All @@ -61,14 +77,30 @@ class ArticleOngrDocument
/**
* @var string
*
* @Property(type="string")
* @Property(
* type="string",
* options={
* "fields"={
* "raw"={"type"="string", "index"="not_analyzed"},
* "value"={"type"="string"}
* }
* }
* )
*/
protected $changer;

/**
* @var string
*
* @Property(type="string")
* @Property(
* type="string",
* options={
* "fields"={
* "raw"={"type"="string", "index"="not_analyzed"},
* "value"={"type"="string"}
* }
* }
* )
*/
protected $creator;

Expand Down
30 changes: 27 additions & 3 deletions Document/ExcerptOngrObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,45 @@ class ExcerptOngrObject
/**
* @var string
*
* @Property(type="string")
* @Property(
* type="string",
* options={
* "fields"={
* "raw"={"type"="string", "index"="not_analyzed"},
* "value"={"type"="string"}
* }
* }
* )
*/
public $title;

/**
* @var string
*
* @Property(type="string")
* @Property(
* type="string",
* options={
* "fields"={
* "raw"={"type"="string", "index"="not_analyzed"},
* "value"={"type"="string"}
* }
* }
* )
*/
public $more;

/**
* @var string
*
* @Property(type="string")
* @Property(
* type="string",
* options={
* "fields"={
* "raw"={"type"="string", "index"="not_analyzed"},
* "value"={"type"="string"}
* }
* }
* )
*/
public $description;

Expand Down
40 changes: 36 additions & 4 deletions Document/SeoOngrObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,60 @@ class SeoOngrObject
/**
* @var string
*
* @Property(type="string")
* @Property(
* type="string",
* options={
* "fields"={
* "raw"={"type"="string", "index"="not_analyzed"},
* "value"={"type"="string"}
* }
* }
* )
*/
public $title;

/**
* @var string
*
* @Property(type="string")
* @Property(
* type="string",
* options={
* "fields"={
* "raw"={"type"="string", "index"="not_analyzed"},
* "value"={"type"="string"}
* }
* }
* )
*/
public $description;

/**
* @var string
*
* @Property(type="string")
* @Property(
* type="string",
* options={
* "fields"={
* "raw"={"type"="string", "index"="not_analyzed"},
* "value"={"type"="string"}
* }
* }
* )
*/
public $keywords;

/**
* @var string
*
* @Property(type="string")
* @Property(
* type="string",
* options={
* "fields"={
* "raw"={"type"="string", "index"="not_analyzed"},
* "value"={"type"="string"}
* }
* }
* )
*/
public $canonicalUrl;

Expand Down

0 comments on commit e3447d3

Please sign in to comment.