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
41e36c5e
Commit
41e36c5e
authored
10 years ago
by
Mantas Jonušas
Browse files
Options
Downloads
Patches
Plain Diff
Added missing DSL queries
parent
67e1a417
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Query/BoostingQuery.php
+69
-0
69 additions, 0 deletions
Query/BoostingQuery.php
Query/DisMaxQuery.php
+69
-0
69 additions, 0 deletions
Query/DisMaxQuery.php
Query/PrefixQuery.php
+69
-0
69 additions, 0 deletions
Query/PrefixQuery.php
with
207 additions
and
0 deletions
Query/BoostingQuery.php
0 → 100644
+
69
−
0
View file @
41e36c5e
<?php
/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <info@nfq.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
ONGR\ElasticsearchBundle\DSL\Query
;
use
ONGR\ElasticsearchBundle\DSL\BuilderInterface
;
/**
* Elasticsearch boosting query class.
*/
class
BoostingQuery
implements
BuilderInterface
{
/**
* @var BuilderInterface
*/
private
$positive
;
/**
* @var BuilderInterface
*/
private
$negative
;
/**
* @var int|float
*/
private
$negativeBoost
;
/**
* @param BuilderInterface $positive
* @param BuilderInterface $negative
* @param int|float $negativeBoost
*/
public
function
__construct
(
BuilderInterface
$positive
,
BuilderInterface
$negative
,
$negativeBoost
)
{
$this
->
positive
=
$positive
;
$this
->
negative
=
$negative
;
$this
->
negativeBoost
=
$negativeBoost
;
}
/**
* {@inheritdoc}
*/
public
function
getType
()
{
return
'boosting'
;
}
/**
* {@inheritdoc}
*/
public
function
toArray
()
{
$query
=
[
'positive'
=>
[
$this
->
positive
->
getType
()
=>
$this
->
positive
->
toArray
()],
'negative'
=>
[
$this
->
negative
->
getType
()
=>
$this
->
negative
->
toArray
()],
'negative_boost'
=>
$this
->
negativeBoost
,
];
return
$query
;
}
}
This diff is collapsed.
Click to expand it.
Query/DisMaxQuery.php
0 → 100644
+
69
−
0
View file @
41e36c5e
<?php
/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <info@nfq.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
ONGR\ElasticsearchBundle\DSL\Query
;
use
ONGR\ElasticsearchBundle\DSL\BuilderInterface
;
use
ONGR\ElasticsearchBundle\DSL\ParametersTrait
;
/**
* Elasticsearch dis max query class.
*/
class
DisMaxQuery
implements
BuilderInterface
{
use
ParametersTrait
;
/**
* @var BuilderInterface[]
*/
private
$queries
=
[];
/**
* Initializes Dis Max query.
*
* @param BuilderInterface[] $queries
* @param array $parameters
*
* @throws \InvalidArgumentException
*/
public
function
__construct
(
array
$queries
=
[],
array
$parameters
=
[])
{
foreach
(
$queries
as
$query
)
{
if
(
$query
instanceof
BuilderInterface
)
{
$this
->
queries
[]
=
$query
;
}
else
{
throw
new
\InvalidArgumentException
(
'Arguments must be instance of BuilderInterface'
);
}
}
$this
->
setParameters
(
$parameters
);
}
/**
* {@inheritdoc}
*/
public
function
getType
()
{
return
'dis_max'
;
}
/**
* {@inheritdoc}
*/
public
function
toArray
()
{
foreach
(
$this
->
queries
as
$type
)
{
$query
[
'queries'
][]
=
[
$type
->
getType
()
=>
$type
->
toArray
()];
}
$output
=
$this
->
processArray
(
$query
);
return
$output
;
}
}
This diff is collapsed.
Click to expand it.
Query/PrefixQuery.php
0 → 100644
+
69
−
0
View file @
41e36c5e
<?php
/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <info@nfq.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
ONGR\ElasticsearchBundle\DSL\Query
;
use
ONGR\ElasticsearchBundle\DSL\BuilderInterface
;
use
ONGR\ElasticsearchBundle\DSL\ParametersTrait
;
/**
* Represents Elasticsearch "prefix" query.
*/
class
PrefixQuery
implements
BuilderInterface
{
use
ParametersTrait
;
/**
* @var string
*/
private
$field
;
/**
* @var string
*/
private
$value
;
/**
* @param string $field Field name.
* @param string $value Value.
* @param array $parameters Optional parameters.
*/
public
function
__construct
(
$field
,
$value
,
array
$parameters
=
[])
{
$this
->
field
=
$field
;
$this
->
value
=
$value
;
$this
->
setParameters
(
$parameters
);
}
/**
* {@inheritdoc}
*/
public
function
getType
()
{
return
'prefix'
;
}
/**
* {@inheritdoc}
*/
public
function
toArray
()
{
$query
=
[
'value'
=>
$this
->
value
,
];
$output
=
[
$this
->
field
=>
$this
->
processArray
(
$query
),
];
return
$output
;
}
}
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