-
Notifications
You must be signed in to change notification settings - Fork 25.5k
[DOCS] Add search and filtering tutorial/quickstart, edit filtering page #114353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
4438d2a
f32b83a
59d98cc
acd0055
549f110
7a0ead7
3abc6c8
23f292a
92e47af
a3c6c87
262a15b
75c52de
e00dbbd
7d92427
4ca8132
b677609
faa12a5
9970a34
0de3031
83b409a
dacbe7c
1295518
b46725a
0624b19
ab1f11b
df4184a
2488afd
9589b6a
9cce834
3eafe1b
a083d42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,26 +29,35 @@ parameter, such as the `query` parameter in the | |
[discrete] | ||
[[filter-context]] | ||
=== Filter context | ||
In a filter context, a query clause answers the question ``__Does this | ||
document match this query clause?__'' The answer is a simple Yes or No -- no | ||
scores are calculated. Filter context is mostly used for filtering structured | ||
data, e.g. | ||
|
||
* __Does this +timestamp+ fall into the range 2015 to 2016?__ | ||
* __Is the +status+ field set to ++"published"++__? | ||
A filter answers the binary question “Does this document match this query clause?”. The answer is simply "yes" or "no". | ||
Filtering has several benefits: | ||
|
||
Frequently used filters will be cached automatically by Elasticsearch, to | ||
speed up performance. | ||
. *Simple binary logic*: In a filter context, a query clause determines document matches based on a yes/no criterion, without score calculation. | ||
. *Performance*: Because they don't compute relevance scores, filters execute faster than queries. | ||
. *Caching*: {es} automatically caches frequently used filters, speeding up subsequent search performance. | ||
. *Resource efficiency*: Filters consume less CPU resources compared to full-text queries. | ||
. *Query combination*: Filters can be combined with scored queries to refine result sets efficiently. | ||
|
||
Filter context is in effect whenever a query clause is passed to a `filter` | ||
parameter, such as the `filter` or `must_not` parameters in the | ||
<<query-dsl-bool-query,`bool`>> query, the `filter` parameter in the | ||
<<query-dsl-constant-score-query,`constant_score`>> query, or the | ||
<<search-aggregations-bucket-filter-aggregation,`filter`>> aggregation. | ||
Filters are particularly effective for querying structured data and implementing "must have" criteria in complex searches. | ||
|
||
Common filter applications include: | ||
|
||
* Date range checks: for example is the `timestamp` field between 2015 and 2016 | ||
* Status checks: for example is the `status` field equal to "published" | ||
leemthompo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
Filter context applies when a query clause is passed to a `filter` parameter, such as: | ||
|
||
* `filter` or `must_not` parameters in <<query-dsl-bool-query,`bool`>> queries | ||
* `filter` parameter in <<query-dsl-constant-score-query,`constant_score`>> queries | ||
* <<search-aggregations-bucket-filter-aggregation,`filter`>> aggregations | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @carlosdelest sorry I forgot that I edited this page too, so I glanced over this comment as if it related to the tutorial! Indeed we should add whatever else is missing from this query_filter_context.asciidoc page too 😄 |
||
|
||
Filters optimize query performance and efficiency, especially for structured data queries and when combined with full-text searches. | ||
|
||
[discrete] | ||
[[query-filter-context-ex]] | ||
=== Example of query and filter contexts | ||
|
||
Below is an example of query clauses being used in query and filter context | ||
in the `search` API. This query will match documents where all of the following | ||
conditions are met: | ||
|
Uh oh!
There was an error while loading. Please reload this page.