-
Notifications
You must be signed in to change notification settings - Fork 578
adding wrapper dsl query docs #9939
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
Merged
natebower
merged 5 commits into
opensearch-project:main
from
AntonEliatra:adding-wrapper-dsl-query-docs
Jul 8, 2025
+97
−1
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f59b046
adding wrapper dsl query docs
AntonEliatra 38e2e84
adding changes to the docs
AntonEliatra 35862ca
addressing the PR comments
AntonEliatra 2cc2ac9
Apply suggestions from code review
AntonEliatra 243ff5e
Update _query-dsl/specialized/wrapper.md
natebower File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
--- | ||
|
||
layout: default | ||
title: Wrapper | ||
parent: Specialized queries | ||
nav_order: 80 | ||
--- | ||
|
||
# Wrapper | ||
|
||
The `wrapper` query lets you submit a complete query in Base64-encoded JSON format. It is useful when the query must be embedded in contexts that only support string values. | ||
|
||
Use this query only when you need to manage system constraints. For readability and maintainability, it's better to use standard JSON-based queries when possible. | ||
|
||
## Example | ||
|
||
Create an index named `products` with the following mappings: | ||
|
||
```json | ||
PUT /products | ||
{ | ||
"mappings": { | ||
"properties": { | ||
"title": { "type": "text" } | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
Index sample documents: | ||
|
||
```json | ||
POST /products/_bulk | ||
{ "index": { "_id": 1 } } | ||
{ "title": "Wireless headphones with noise cancellation" } | ||
{ "index": { "_id": 2 } } | ||
{ "title": "Bluetooth speaker" } | ||
{ "index": { "_id": 3 } } | ||
{ "title": "Over-ear headphones with rich bass" } | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
Encode the following query in Base64 format: | ||
|
||
```bash | ||
echo -n '{ "match": { "title": "headphones" } }' | base64 | ||
``` | ||
{% include copy.html %} | ||
|
||
Execute the encoded query: | ||
|
||
```json | ||
POST /products/_search | ||
{ | ||
"query": { | ||
"wrapper": { | ||
"query": "eyAibWF0Y2giOiB7ICJ0aXRsZSI6ICJoZWFkcGhvbmVzIiB9IH0=" | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
The response contains the two matching documents: | ||
|
||
```json | ||
{ | ||
... | ||
"hits": { | ||
"total": { | ||
"value": 2, | ||
"relation": "eq" | ||
}, | ||
"max_score": 0.20098841, | ||
"hits": [ | ||
{ | ||
"_index": "products", | ||
"_id": "1", | ||
"_score": 0.20098841, | ||
"_source": { | ||
"title": "Wireless headphones with noise cancellation" | ||
} | ||
}, | ||
{ | ||
"_index": "products", | ||
"_id": "3", | ||
"_score": 0.18459359, | ||
"_source": { | ||
"title": "Over-ear headphones with rich bass" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.