File tree Expand file tree Collapse file tree 2 files changed +92
-0
lines changed 
_observing-your-data/query-insights Expand file tree Collapse file tree 2 files changed +92
-0
lines changed Original file line number Diff line number Diff line change 4545
4646When queries share the same query structure, they are grouped together, ensuring that all similar queries belong to the same group.
4747
48+ ## Configuring the query structure  
49+ 
50+ The preceding example query shows a simplified query structure. By default, the query structure also includes field names and field data types. 
51+ 
52+ For example, consider an index ` index1 `  with the following field mapping:
53+ 
54+ ``` json 
55+ "mappings" : {
56+   "properties" : {
57+     "field1" : {
58+       "type" : " keyword" 
59+     },
60+     "field2" : {
61+       "type" : " text" 
62+     },
63+     "field3" : {
64+       "type" : " text" 
65+     },
66+     "field4" : {
67+       "type" : " long" 
68+     }
69+   }
70+ }
71+ ``` 
72+ 
73+ If you run the following query on this index:
74+ 
75+ ``` json 
76+ {
77+   "query" : {
78+     "bool" : {
79+       "must" : [
80+         {
81+           "term" : {
82+             "field1" : " example_value" 
83+           }
84+         }
85+       ],
86+       "filter" : [
87+         {
88+           "match" : {
89+             "field2" : " search_text" 
90+           }
91+         },
92+         {
93+           "range" : {
94+             "field4" : {
95+               "gte" : 1 ,
96+               "lte" : 100 
97+             }
98+           }
99+         }
100+       ],
101+       "should" : [
102+         {
103+           "regexp" : {
104+             "field3" : " .*" 
105+           }
106+         }
107+       ]
108+     }
109+   }
110+ }
111+ ``` 
112+ 
113+ Then the query has the following corresponding query structure:
114+ 
115+ ``` c 
116+ bool  []
117+   must:
118+     term [field1, keyword]
119+   filter:
120+     match [field2, text]
121+     range [field4, long ]
122+   should:
123+     regexp [field3, text]
124+ ``` 
125+ 
126+ To exclude field names and field data types from the query structure, configure the following settings:
127+ 
128+ ``` json 
129+ PUT _cluster/settings 
130+ {
131+   "persistent"  : {
132+     "search.insights.top_queries.grouping.attributes.field_name"  : false ,
133+     "search.insights.top_queries.grouping.attributes.field_type"  : false 
134+   }
135+ }
136+ ``` 
137+ {% include copy-curl.html %}
48138
49139## Aggregate metrics per group  
50140
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ title: Query insights
44nav_order : 40 
55has_children : true 
66has_toc : false 
7+ redirect_from :
8+   - /query-insights/ 
79--- 
810
911# Query insights  
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments