Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
Elasticsearch DSL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Public
Elasticsearch DSL
Commits
10285406
Commit
10285406
authored
9 years ago
by
Martynas Sudintas
Browse files
Options
Downloads
Patches
Plain Diff
Highlight is now implementing builder interface
parent
73a63dea
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Highlight/Highlight.php
+25
-5
25 additions, 5 deletions
Highlight/Highlight.php
with
25 additions
and
5 deletions
Highlight/Highlight.php
+
25
−
5
View file @
10285406
...
...
@@ -11,13 +11,14 @@
namespace
ONGR\ElasticsearchBundle\DSL\Highlight
;
use
ONGR\ElasticsearchBundle\DSL\BuilderInterface
;
use
ONGR\ElasticsearchBundle\DSL\NamedBuilderBag
;
use
ONGR\ElasticsearchBundle\DSL\NamedBuilderInterface
;
/**
* Data holder for highlight api.
*/
class
Highlight
extends
NamedBuilderBag
class
Highlight
extends
NamedBuilderBag
implements
BuilderInterface
{
const
TYPE_PLAIN
=
'plain'
;
const
TYPE_POSTINGS
=
'postings'
;
...
...
@@ -170,6 +171,14 @@ class Highlight extends NamedBuilderBag
return
$this
;
}
/**
* {@inheritdoc}
*/
public
function
getType
()
{
return
'highlight'
;
}
/**
* {@inheritdoc}
*/
...
...
@@ -182,6 +191,7 @@ class Highlight extends NamedBuilderBag
'fragment_size'
=>
$this
->
fragmentSize
,
'number_of_fragments'
=>
$this
->
numberOfFragments
,
'tags_schema'
=>
$this
->
tagsSchema
,
'fields'
=>
$this
->
getFields
(),
]
);
...
...
@@ -197,11 +207,21 @@ class Highlight extends NamedBuilderBag
}
}
/** @var NamedBuilderInterface $field */
foreach
(
$this
->
all
()
as
$field
)
{
$highlight
[
'fields'
][
$field
->
getName
()]
=
$field
->
toArray
();
return
$highlight
;
}
/**
* Returns fields as array.
*
* @return array
*/
private
function
getFields
()
{
$out
=
[];
foreach
(
$this
->
all
()
as
$builder
)
{
$out
=
array_merge
(
$out
,
[
$builder
->
getName
()
=>
$builder
->
toArray
()]);
}
return
$
highligh
t
;
return
$
ou
t
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment