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
c0b75cf1
Commit
c0b75cf1
authored
10 years ago
by
Mantas Jonušas
Browse files
Options
Downloads
Patches
Plain Diff
Implemented addQuery method in SpanOr and SpanNear queries
parent
752a57f1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Query/Span/SpanNearQuery.php
+11
-19
11 additions, 19 deletions
Query/Span/SpanNearQuery.php
Query/Span/SpanOrQuery.php
+25
-8
25 additions, 8 deletions
Query/Span/SpanOrQuery.php
with
36 additions
and
27 deletions
Query/Span/SpanNearQuery.php
+
11
−
19
View file @
c0b75cf1
...
...
@@ -11,37 +11,30 @@
namespace
ONGR\ElasticsearchBundle\DSL\Query\Span
;
use
ONGR\ElasticsearchBundle\DSL\ParametersTrait
;
/**
* Elasticsearch span near query.
*/
class
SpanNearQuery
implements
SpanQueryInterface
class
SpanNearQuery
extends
SpanOrQuery
implements
SpanQueryInterface
{
use
ParametersTrait
;
/**
* @var int
*/
private
$slop
;
/**
* @
var SpanQueryInterface[]
* @
return int
*/
private
$queries
=
[];
public
function
getSlop
()
{
return
$this
->
slop
;
}
/**
* @param int $slop
* @param SpanQueryInterface[] $queries
* @param array $parameters
*
* @throws \LogicException
* @param int $slop
*/
public
function
__construct
(
$slop
,
array
$queries
=
[],
array
$parameters
=
[]
)
public
function
setSlop
(
$slop
)
{
$this
->
slop
=
$slop
;
$this
->
queries
=
$queries
;
$this
->
setParameters
(
$parameters
);
}
/**
...
...
@@ -58,11 +51,10 @@ class SpanNearQuery implements SpanQueryInterface
public
function
toArray
()
{
$query
=
[];
foreach
(
$this
->
queries
as
$type
)
{
$data
=
[
$type
->
getType
()
=>
$type
->
toArray
()];
$query
[
'clauses'
][]
=
$data
;
foreach
(
$this
->
getQueries
()
as
$type
)
{
$query
[
'clauses'
][]
=
[
$type
->
getType
()
=>
$type
->
toArray
()];
}
$query
[
'slop'
]
=
$this
->
s
lop
;
$query
[
'slop'
]
=
$this
->
getS
lop
()
;
$output
=
$this
->
processArray
(
$query
);
return
$output
;
...
...
This diff is collapsed.
Click to expand it.
Query/Span/SpanOrQuery.php
+
25
−
8
View file @
c0b75cf1
...
...
@@ -26,17 +26,35 @@ class SpanOrQuery implements SpanQueryInterface
private
$queries
=
[];
/**
* @param SpanQueryInterface[] $queries
* @param array $parameters
* @param array $parameters
*/
public
function
__construct
(
array
$queries
=
[],
array
$parameters
=
[])
public
function
__construct
(
array
$parameters
=
[])
{
foreach
(
$queries
as
$query
)
{
$this
->
queries
[]
=
$query
;
}
$this
->
setParameters
(
$parameters
);
}
/**
* Add span query.
*
* @param SpanQueryInterface $query
*
* @return $this
*/
public
function
addQuery
(
SpanQueryInterface
$query
)
{
$this
->
queries
[]
=
$query
;
return
$this
;
}
/**
* @return SpanQueryInterface[]
*/
public
function
getQueries
()
{
return
$this
->
queries
;
}
/**
* {@inheritdoc}
*/
...
...
@@ -52,8 +70,7 @@ class SpanOrQuery implements SpanQueryInterface
{
$query
=
[];
foreach
(
$this
->
queries
as
$type
)
{
$data
=
[
$type
->
getType
()
=>
$type
->
toArray
()];
$query
[
'clauses'
][]
=
$data
;
$query
[
'clauses'
][]
=
[
$type
->
getType
()
=>
$type
->
toArray
()];
}
$output
=
$this
->
processArray
(
$query
);
...
...
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