Skip to content

Commit 93e8792

Browse files
philkradelvedor
andauthored
Fix search Request (#390)
* improve search request * Fixded Geo distance query * Updated output * Fix nested sort * Updated output Co-authored-by: delvedor <[email protected]>
1 parent 3a7a52a commit 93e8792

File tree

7 files changed

+116
-46
lines changed

7 files changed

+116
-46
lines changed

output/schema/schema.json

Lines changed: 87 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24181,7 +24181,7 @@
2418124181
"properties": [
2418224182
{
2418324183
"name": "filter",
24184-
"required": true,
24184+
"required": false,
2418524185
"type": {
2418624186
"kind": "instance_of",
2418724187
"type": {
@@ -50045,6 +50045,18 @@
5004550045
}
5004650046
}
5004750047
},
50048+
{
50049+
"name": "combined_fields",
50050+
"required": false,
50051+
"since": "7.13.0",
50052+
"type": {
50053+
"kind": "instance_of",
50054+
"type": {
50055+
"name": "CombinedFieldsQuery",
50056+
"namespace": "_types.query_dsl.abstractions.query"
50057+
}
50058+
}
50059+
},
5004850060
{
5004950061
"name": "constant_score",
5005050062
"required": false,
@@ -50205,31 +50217,10 @@
5020550217
"name": "geo_distance",
5020650218
"required": false,
5020750219
"type": {
50208-
"generics": [
50209-
{
50210-
"items": [
50211-
{
50212-
"kind": "instance_of",
50213-
"type": {
50214-
"name": "GeoDistanceQuery",
50215-
"namespace": "_types.query_dsl.geo.distance"
50216-
}
50217-
},
50218-
{
50219-
"kind": "instance_of",
50220-
"type": {
50221-
"name": "string",
50222-
"namespace": "internal"
50223-
}
50224-
}
50225-
],
50226-
"kind": "union_of"
50227-
}
50228-
],
5022950220
"kind": "instance_of",
5023050221
"type": {
50231-
"name": "NamedQuery",
50232-
"namespace": "_types.query_dsl.abstractions.query"
50222+
"name": "GeoDistanceQuery",
50223+
"namespace": "_types.query_dsl.geo.distance"
5023350224
}
5023450225
}
5023550226
},
@@ -51163,6 +51154,51 @@
5116351154
}
5116451155
]
5116551156
},
51157+
{
51158+
"kind": "interface",
51159+
"name": {
51160+
"name": "CombinedFieldsQuery",
51161+
"namespace": "_types.query_dsl.abstractions.query"
51162+
},
51163+
"properties": [
51164+
{
51165+
"name": "query",
51166+
"required": true,
51167+
"type": {
51168+
"kind": "instance_of",
51169+
"type": {
51170+
"name": "string",
51171+
"namespace": "internal"
51172+
}
51173+
}
51174+
},
51175+
{
51176+
"name": "fields",
51177+
"required": true,
51178+
"type": {
51179+
"kind": "array_of",
51180+
"value": {
51181+
"kind": "instance_of",
51182+
"type": {
51183+
"name": "Field",
51184+
"namespace": "_types"
51185+
}
51186+
}
51187+
}
51188+
},
51189+
{
51190+
"name": "operator",
51191+
"required": false,
51192+
"type": {
51193+
"kind": "instance_of",
51194+
"type": {
51195+
"name": "string",
51196+
"namespace": "internal"
51197+
}
51198+
}
51199+
}
51200+
]
51201+
},
5116651202
{
5116751203
"attachedBehaviors": [
5116851204
"AdditionalProperties"
@@ -54437,6 +54473,33 @@
5443754473
}
5443854474
},
5443954475
{
54476+
"attachedBehaviors": [
54477+
"AdditionalProperties"
54478+
],
54479+
"behaviors": [
54480+
{
54481+
"generics": [
54482+
{
54483+
"kind": "instance_of",
54484+
"type": {
54485+
"name": "string",
54486+
"namespace": "internal"
54487+
}
54488+
},
54489+
{
54490+
"kind": "instance_of",
54491+
"type": {
54492+
"name": "GeoLocation",
54493+
"namespace": "_types.query_dsl.geo"
54494+
}
54495+
}
54496+
],
54497+
"type": {
54498+
"name": "AdditionalProperties",
54499+
"namespace": "_spec_utils"
54500+
}
54501+
}
54502+
],
5444054503
"inherits": {
5444154504
"type": {
5444254505
"name": "QueryBase",
@@ -54471,17 +54534,6 @@
5447154534
}
5447254535
}
5447354536
},
54474-
{
54475-
"name": "location",
54476-
"required": false,
54477-
"type": {
54478-
"kind": "instance_of",
54479-
"type": {
54480-
"name": "GeoLocation",
54481-
"namespace": "_types.query_dsl.geo"
54482-
}
54483-
}
54484-
},
5448554537
{
5448654538
"name": "validation_method",
5448754539
"required": false,

output/typescript/types.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ export type SearchSortGeoDistanceSort = SearchSortGeoDistanceSortKeys |
12901290
{ [property: string]: QueryDslGeoGeoLocation | QueryDslGeoGeoLocation[] }
12911291

12921292
export interface SearchSortNestedSortValue {
1293-
filter: QueryDslAbstractionsContainerQueryContainer
1293+
filter?: QueryDslAbstractionsContainerQueryContainer
12941294
max_children?: integer
12951295
path: Field
12961296
}
@@ -4108,14 +4108,15 @@ export interface QueryDslAbstractionsContainerQueryContainer {
41084108
bool?: QueryDslCompoundBoolBoolQuery
41094109
boosting?: QueryDslCompoundBoostingBoostingQuery
41104110
common?: Record<Field, QueryDslFullTextCommonTermsCommonTermsQuery | string>
4111+
combined_fields?: QueryDslAbstractionsQueryCombinedFieldsQuery
41114112
constant_score?: QueryDslCompoundConstantScoreConstantScoreQuery
41124113
dis_max?: QueryDslCompoundDismaxDisMaxQuery
41134114
distance_feature?: Record<Field, QueryDslSpecializedDistanceFeatureDistanceFeatureQuery | string> | QueryDslSpecializedDistanceFeatureDistanceFeatureQuery
41144115
exists?: QueryDslTermLevelExistsExistsQuery
41154116
function_score?: QueryDslCompoundFunctionScoreFunctionScoreQuery
41164117
fuzzy?: Record<Field, QueryDslTermLevelFuzzyFuzzyQuery | string>
41174118
geo_bounding_box?: QueryDslAbstractionsQueryNamedQuery<QueryDslGeoBoundingBoxGeoBoundingBoxQuery | string>
4118-
geo_distance?: QueryDslAbstractionsQueryNamedQuery<QueryDslGeoDistanceGeoDistanceQuery | string>
4119+
geo_distance?: QueryDslGeoDistanceGeoDistanceQuery
41194120
geo_polygon?: QueryDslAbstractionsQueryNamedQuery<QueryDslGeoPolygonGeoPolygonQuery | string>
41204121
geo_shape?: QueryDslAbstractionsQueryNamedQuery<QueryDslGeoShapeGeoShapeQuery | string>
41214122
has_child?: QueryDslJoiningHasChildHasChildQuery
@@ -4171,6 +4172,12 @@ export interface QueryDslAbstractionsFieldLookupFieldLookup {
41714172
routing?: Routing
41724173
}
41734174

4175+
export interface QueryDslAbstractionsQueryCombinedFieldsQuery {
4176+
query: string
4177+
fields: Field[]
4178+
operator?: string
4179+
}
4180+
41744181
export interface QueryDslAbstractionsQueryNamedQueryKeys<TQuery = unknown> {
41754182
boost?: float
41764183
_name?: string
@@ -4514,12 +4521,13 @@ export interface QueryDslGeoBoundingBoxGeoBoundingBoxQuery extends QueryDslAbstr
45144521

45154522
export type QueryDslGeoBoundingBoxGeoExecution = 'memory' | 'indexed'
45164523

4517-
export interface QueryDslGeoDistanceGeoDistanceQuery extends QueryDslAbstractionsQueryQueryBase {
4524+
export interface QueryDslGeoDistanceGeoDistanceQueryKeys extends QueryDslAbstractionsQueryQueryBase {
45184525
distance?: Distance
45194526
distance_type?: GeoDistanceType
4520-
location?: QueryDslGeoGeoLocation
45214527
validation_method?: QueryDslGeoGeoValidationMethod
45224528
}
4529+
export type QueryDslGeoDistanceGeoDistanceQuery = QueryDslGeoDistanceGeoDistanceQueryKeys |
4530+
{ [property: string]: QueryDslGeoGeoLocation }
45234531

45244532
export interface QueryDslGeoPolygonGeoPolygonQuery extends QueryDslAbstractionsQueryQueryBase {
45254533
points?: QueryDslGeoGeoLocation[]

specification/_global/search/SearchRequest.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ export interface Request extends RequestBase {
110110
from?: integer
111111
highlight?: Highlight
112112
track_total_hits?: boolean | integer
113-
/** @prop_serializer IndicesBoostFormatter */
114113
indices_boost?: Array<Dictionary<IndexName, double>>
115114
docvalue_fields?: DocValueField | Array<Field | DocValueField>
116115
min_score?: double

specification/_global/search/sort/NestedSort.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import { integer } from '@_types/Numeric'
2222
import { QueryContainer } from '@_types/query_dsl/abstractions/container/QueryContainer'
2323

2424
export class NestedSortValue {
25-
filter: QueryContainer
25+
filter?: QueryContainer
2626
max_children?: integer
2727
path: Field
28-
//nested: NestedSortValue
28+
// nested: NestedSortValue
2929
}
3030

3131
// export type NestedSort = Dictionary<Field, NestedSortKey>

specification/_types/query_dsl/abstractions/container/QueryContainer.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import { TermsQuery } from '@_types/query_dsl/term_level/terms/TermsQuery'
7171
import { TermsSetQuery } from '@_types/query_dsl/term_level/terms_set/TermsSetQuery'
7272
import { TypeQuery } from '@_types/query_dsl/term_level/type/TypeQuery'
7373
import { WildcardQuery } from '@_types/query_dsl/term_level/wildcard/WildcardQuery'
74-
import { NamedQuery } from '../query/Query'
74+
import { CombinedFieldsQuery, NamedQuery } from '../query/Query'
7575
import { QueryTemplate } from './QueryTemplate'
7676
import { Field } from '@_types/common'
7777

@@ -82,6 +82,8 @@ export class QueryContainer {
8282
bool?: BoolQuery
8383
boosting?: BoostingQuery
8484
common?: SingleKeyDictionary<Field, CommonTermsQuery | string>
85+
/** @since 7.13.0 */
86+
combined_fields?: CombinedFieldsQuery
8587
constant_score?: ConstantScoreQuery
8688
dis_max?: DisMaxQuery
8789
// TODO?: can be both { __field__ ?: { options } } and { field?: "" ...options }
@@ -93,7 +95,7 @@ export class QueryContainer {
9395
function_score?: FunctionScoreQuery
9496
fuzzy?: SingleKeyDictionary<Field, FuzzyQuery | string>
9597
geo_bounding_box?: NamedQuery<GeoBoundingBoxQuery | string>
96-
geo_distance?: NamedQuery<GeoDistanceQuery | string>
98+
geo_distance?: GeoDistanceQuery
9799
geo_polygon?: NamedQuery<GeoPolygonQuery | string>
98100
geo_shape?: NamedQuery<GeoShapeQuery | string>
99101
has_child?: HasChildQuery

specification/_types/query_dsl/abstractions/query/Query.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
import { AdditionalProperties } from '@spec_utils/behaviors'
21+
import { Field } from '@_types/common'
2122
import { float } from '@_types/Numeric'
2223

2324
export class QueryBase {
@@ -38,3 +39,9 @@ export class NamedQuery<TQuery>
3839
_name?: string
3940
ignore_unmapped?: boolean
4041
}
42+
43+
export class CombinedFieldsQuery {
44+
query: string
45+
fields: Field[]
46+
operator?: string
47+
}

specification/_types/query_dsl/geo/distance/GeoDistanceQuery.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@
1717
* under the License.
1818
*/
1919

20+
import { AdditionalProperties } from '@spec_utils/behaviors'
2021
import { Distance, GeoDistanceType } from '@_types/Geo'
2122
import { QueryBase } from '@_types/query_dsl/abstractions/query/Query'
2223
import { GeoLocation } from '../GeoLocation'
2324
import { GeoValidationMethod } from '../GeoValidationMethod'
2425

25-
export class GeoDistanceQuery extends QueryBase {
26+
export class GeoDistanceQuery
27+
extends QueryBase
28+
implements AdditionalProperties<string, GeoLocation> {
2629
distance?: Distance
2730
distance_type?: GeoDistanceType
28-
location?: GeoLocation
2931
validation_method?: GeoValidationMethod
3032
}

0 commit comments

Comments
 (0)