Skip to content

Commit

Permalink
Documentation for query field name and datatype in query shape (opens…
Browse files Browse the repository at this point in the history
…earch-project#8631)

* Documentation for query field name and datatype in query shape

Signed-off-by: Siddhant Deshmukh <[email protected]>

* Address review dog comments

Signed-off-by: Siddhant Deshmukh <[email protected]>

* Doc review

Signed-off-by: Fanit Kolchina <[email protected]>

* Update _observing-your-data/query-insights/grouping-top-n-queries.md

Co-authored-by: Nathan Bower <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>

* Rewording

Signed-off-by: Fanit Kolchina <[email protected]>

---------

Signed-off-by: Siddhant Deshmukh <[email protected]>
Signed-off-by: Fanit Kolchina <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>
Co-authored-by: Fanit Kolchina <[email protected]>
Co-authored-by: kolchfa-aws <[email protected]>
Co-authored-by: Nathan Bower <[email protected]>
Signed-off-by: Eric Pugh <[email protected]>
  • Loading branch information
4 people authored and epugh committed Nov 23, 2024
1 parent d4c86af commit bacde8d
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
90 changes: 90 additions & 0 deletions _observing-your-data/query-insights/grouping-top-n-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,96 @@ bool

When queries share the same query structure, they are grouped together, ensuring that all similar queries belong to the same group.

## Configuring the query structure

The preceding example query shows a simplified query structure. By default, the query structure also includes field names and field data types.

For example, consider an index `index1` with the following field mapping:

```json
"mappings": {
"properties": {
"field1": {
"type": "keyword"
},
"field2": {
"type": "text"
},
"field3": {
"type": "text"
},
"field4": {
"type": "long"
}
}
}
```

If you run the following query on this index:

```json
{
"query": {
"bool": {
"must": [
{
"term": {
"field1": "example_value"
}
}
],
"filter": [
{
"match": {
"field2": "search_text"
}
},
{
"range": {
"field4": {
"gte": 1,
"lte": 100
}
}
}
],
"should": [
{
"regexp": {
"field3": ".*"
}
}
]
}
}
}
```

Then the query has the following corresponding query structure:

```c
bool []
must:
term [field1, keyword]
filter:
match [field2, text]
range [field4, long]
should:
regexp [field3, text]
```

To exclude field names and field data types from the query structure, configure the following settings:

```json
PUT _cluster/settings
{
"persistent" : {
"search.insights.top_queries.grouping.attributes.field_name" : false,
"search.insights.top_queries.grouping.attributes.field_type" : false
}
}
```
{% include copy-curl.html %}

## Aggregate metrics per group

Expand Down
2 changes: 2 additions & 0 deletions _observing-your-data/query-insights/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ title: Query insights
nav_order: 40
has_children: true
has_toc: false
redirect_from:
- /query-insights/
---

# Query insights
Expand Down

0 comments on commit bacde8d

Please sign in to comment.