Commit 77cb0ab
committed
Query refactoring: QueryBuilder to extend Writeable
`QueryBuilder`s need to become streamable over the wire, so we can use them as our own intermediate query representation and send it over the wire. Using `Writeable` rather than `Streamable` allows us to make some fields `final` and delete default constructors needed only for serialization purposes.
Taken the chance also to revise the internals of `IdsQueryBuilder` (modified some internal data type and added deduplication of ids to reduce bits to serialize). Expanded also `IdsQueryBuilderTest`, injected random types and improved comparison.
Moved all query builder tests to leverage lucene's equals and hashcode to compare result of `toQuery` with expected lucene query
Also refactored spanterm and term query tests, more core could be shared.
Also changed `RangeQueryBuilderTest` to remove the need for query rewriting and added some more coverage (we don't test when search context is null only anymore, search context gets now randomly set)
Closes elastic#111911 parent 86218bc commit 77cb0ab
File tree
16 files changed
+394
-290
lines changed- src
- main/java/org/elasticsearch/index/query
- test/java/org/elasticsearch/index/query
16 files changed
+394
-290
lines changedLines changed: 11 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
32 | | - | |
| 30 | + | |
| 31 | + | |
33 | 32 | | |
34 | | - | |
| 33 | + | |
35 | 34 | | |
36 | 35 | | |
37 | | - | |
| 36 | + | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
| |||
116 | 115 | | |
117 | 116 | | |
118 | 117 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | 118 | | |
124 | 119 | | |
125 | 120 | | |
| |||
206 | 201 | | |
207 | 202 | | |
208 | 203 | | |
209 | | - | |
210 | 204 | | |
211 | 205 | | |
212 | 206 | | |
213 | 207 | | |
214 | 208 | | |
215 | 209 | | |
216 | 210 | | |
217 | | - | |
218 | 211 | | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
224 | 217 | | |
225 | 218 | | |
226 | | - | |
| 219 | + | |
| 220 | + | |
227 | 221 | | |
228 | 222 | | |
229 | 223 | | |
| |||
Lines changed: 43 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
24 | 23 | | |
25 | 24 | | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | | - | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 35 | + | |
40 | 36 | | |
41 | 37 | | |
42 | 38 | | |
43 | 39 | | |
44 | | - | |
| 40 | + | |
45 | 41 | | |
46 | | - | |
| 42 | + | |
47 | 43 | | |
48 | | - | |
| 44 | + | |
49 | 45 | | |
50 | 46 | | |
51 | 47 | | |
52 | 48 | | |
53 | 49 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
60 | 55 | | |
61 | 56 | | |
62 | 57 | | |
63 | | - | |
64 | | - | |
| 58 | + | |
65 | 59 | | |
66 | | - | |
| 60 | + | |
67 | 61 | | |
68 | 62 | | |
69 | 63 | | |
70 | 64 | | |
71 | 65 | | |
72 | 66 | | |
73 | 67 | | |
74 | | - | |
| 68 | + | |
75 | 69 | | |
76 | 70 | | |
77 | 71 | | |
| |||
83 | 77 | | |
84 | 78 | | |
85 | 79 | | |
86 | | - | |
| 80 | + | |
87 | 81 | | |
88 | | - | |
| 82 | + | |
89 | 83 | | |
90 | 84 | | |
91 | 85 | | |
| |||
125 | 119 | | |
126 | 120 | | |
127 | 121 | | |
128 | | - | |
129 | | - | |
| 122 | + | |
| 123 | + | |
130 | 124 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
| 125 | + | |
136 | 126 | | |
137 | 127 | | |
138 | 128 | | |
139 | 129 | | |
140 | 130 | | |
141 | 131 | | |
142 | 132 | | |
143 | | - | |
| 133 | + | |
144 | 134 | | |
145 | 135 | | |
146 | 136 | | |
| |||
155 | 145 | | |
156 | 146 | | |
157 | 147 | | |
| 148 | + | |
158 | 149 | | |
159 | | - | |
160 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
161 | 160 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 161 | + | |
167 | 162 | | |
168 | | - | |
169 | | - | |
170 | 163 | | |
171 | 164 | | |
172 | 165 | | |
| |||
181 | 174 | | |
182 | 175 | | |
183 | 176 | | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
189 | 183 | | |
190 | 184 | | |
191 | 185 | | |
192 | 186 | | |
193 | | - | |
194 | | - | |
| 187 | + | |
| 188 | + | |
195 | 189 | | |
196 | 190 | | |
197 | 191 | | |
198 | 192 | | |
199 | 193 | | |
200 | 194 | | |
201 | | - | |
| 195 | + | |
202 | 196 | | |
203 | 197 | | |
204 | 198 | | |
| |||
211 | 205 | | |
212 | 206 | | |
213 | 207 | | |
214 | | - | |
| 208 | + | |
215 | 209 | | |
216 | 210 | | |
217 | 211 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
| 34 | + | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
67 | 66 | | |
68 | 67 | | |
69 | 68 | | |
70 | | - | |
71 | 69 | | |
72 | 70 | | |
73 | 71 | | |
| |||
91 | 89 | | |
92 | 90 | | |
93 | 91 | | |
94 | | - | |
95 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
35 | | - | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| |||
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
106 | 120 | | |
0 commit comments