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
ac05db95
Commit
ac05db95
authored
9 years ago
by
Aivaras Gotovskis
Browse files
Options
Downloads
Patches
Plain Diff
Add and filter doc.
parent
c319efab
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
docs/Filter/And.md
+51
-0
51 additions, 0 deletions
docs/Filter/And.md
with
51 additions
and
0 deletions
docs/Filter/And.md
0 → 100644
+
51
−
0
View file @
ac05db95
# And Filter
> More info about and filter is in the [official elasticsearch docs][1]
A filter that matches documents using the AND boolean operator on other filters.
Can be placed within queries that accept a filter.
## Simple example
```
JSON
{
"filtered" : {
"query" : {
"term" : { "name.first" : "shay" }
},
"filter" : {
"and" : [
{
"range" : {
"postDate" : {
"from" : "2010-03-01",
"to" : "2010-04-01"
}
}
},
{
"prefix" : { "name.second" : "ba" }
}
]
}
}
}
```
And now the query via DSL:
```
php
$rangeFilter
=
new
RangeFilter
(
'postDate'
,
[
'from'
=>
'2010-03-01'
,
'to'
=>
'2010-04-01'
]);
$prefixFilter
=
new
PrefixFilter
(
'name.second'
,
'ba'
);
$andFilter
=
new
AndFilter
([
$rangeFilter
,
$prefixFilter
]);
$termQuery
=
new
TermQuery
(
'name.first'
,
'shay'
);
$search
=
new
Search
();
$search
->
addQuery
(
$termQuery
);
$search
->
addFilter
(
$andFilter
);
$queryArray
=
$search
->
toArray
();
```
[
1
]:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-and-filter.html
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