Skip to content

Commit 77722d7

Browse files
committed
feat: add dirty values parameter for single document indexing
- add `dirty_values` parameter for .Create, .Upsert and .Update methods - pull latest oapi-spec changes
1 parent 90638ca commit 77722d7

14 files changed

+139
-91
lines changed

typesense/api/client.go

+6
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ func WithAPIKey(apiKey string) ClientOption {
1616
return nil
1717
}
1818
}
19+
20+
// Manually defining this unreferenced schema here instead of disabling oapi-codegen schema pruning
21+
22+
type DocumentIndexParameters struct {
23+
DirtyValues *DirtyValues `json:"dirty_values,omitempty"`
24+
}

typesense/api/client_gen.go

+37-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typesense/api/generator/generator.yml

+12-5
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ components:
472472
type: string
473473
project_id:
474474
type: string
475+
url:
476+
type: string
475477
required:
476478
- model_name
477479
type: object
@@ -2151,6 +2153,11 @@ paths:
21512153
required: true
21522154
schema:
21532155
type: string
2156+
- description: Dealing with Dirty Data
2157+
in: query
2158+
name: dirty_values
2159+
schema:
2160+
$ref: '#/components/schemas/DirtyValues'
21542161
requestBody:
21552162
content:
21562163
application/json:
@@ -2605,7 +2612,7 @@ paths:
26052612
summary: List all collection overrides
26062613
tags:
26072614
- documents
2608-
- promote
2615+
- curation
26092616
/collections/{collectionName}/overrides/{overrideId}:
26102617
delete:
26112618
operationId: deleteSearchOverride
@@ -2638,7 +2645,7 @@ paths:
26382645
summary: Delete an override associated with a collection
26392646
tags:
26402647
- documents
2641-
- promote
2648+
- curation
26422649
get:
26432650
description: Retrieve the details of a search override, given its id.
26442651
operationId: getSearchOverride
@@ -2705,7 +2712,7 @@ paths:
27052712
summary: Create or update an override to promote certain documents over others
27062713
tags:
27072714
- documents
2708-
- promote
2715+
- curation
27092716
/collections/{collectionName}/synonyms:
27102717
get:
27112718
operationId: getSearchSynonyms
@@ -3657,11 +3664,11 @@ tags:
36573664
description: Find out more
36583665
url: https://typesense.org/api/#index-document
36593666
name: documents
3660-
- description: Promote certain documents over others
3667+
- description: Hand-curate search results based on conditional business rules
36613668
externalDocs:
36623669
description: Find out more
36633670
url: https://typesense.org/docs/0.23.0/api/#curation
3664-
name: promote
3671+
name: curation
36653672
- description: Typesense can aggregate search queries for both analytics purposes and for query suggestions.
36663673
externalDocs:
36673674
description: Find out more

typesense/api/generator/openapi.yml

+24-17
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ tags:
1919
externalDocs:
2020
description: Find out more
2121
url: https://typesense.org/api/#index-document
22-
- name: promote
23-
description: Promote certain documents over others
22+
- name: curation
23+
description: Hand-curate search results based on conditional business rules
2424
externalDocs:
2525
description: Find out more
2626
url: https://typesense.org/docs/0.23.0/api/#curation
@@ -412,7 +412,7 @@ paths:
412412
get:
413413
tags:
414414
- documents
415-
- promote
415+
- curation
416416
summary: List all collection overrides
417417
operationId: getSearchOverrides
418418
parameters:
@@ -460,7 +460,7 @@ paths:
460460
put:
461461
tags:
462462
- documents
463-
- promote
463+
- curation
464464
summary: Create or update an override to promote certain documents over others
465465
description:
466466
Create or update an override to promote certain documents over others.
@@ -502,7 +502,7 @@ paths:
502502
delete:
503503
tags:
504504
- documents
505-
- promote
505+
- curation
506506
summary: Delete an override associated with a collection
507507
operationId: deleteSearchOverride
508508
parameters:
@@ -842,6 +842,11 @@ paths:
842842
required: true
843843
schema:
844844
type: string
845+
- name: dirty_values
846+
in: query
847+
description: Dealing with Dirty Data
848+
schema:
849+
$ref: "#/components/schemas/DirtyValues"
845850
requestBody:
846851
description: The document object with fields to be updated
847852
content:
@@ -1784,12 +1789,12 @@ components:
17841789
maxLength: 1
17851790
default: []
17861791
enable_nested_fields:
1787-
type: boolean
1788-
description:
1789-
Enables experimental support at a collection level for nested object or object array fields.
1790-
This field is only available if the Typesense server is version `0.24.0.rcn34` or later.
1791-
default: false
1792-
example: true
1792+
type: boolean
1793+
description:
1794+
Enables experimental support at a collection level for nested object or object array fields.
1795+
This field is only available if the Typesense server is version `0.24.0.rcn34` or later.
1796+
default: false
1797+
example: true
17931798
symbols_to_index:
17941799
type: array
17951800
description: >
@@ -1919,6 +1924,8 @@ components:
19191924
type: string
19201925
api_key:
19211926
type: string
1927+
url:
1928+
type: string
19221929
access_token:
19231930
type: string
19241931
client_id:
@@ -2436,8 +2443,8 @@ components:
24362443
If infix index is enabled for this field, infix searching can be done on a per-field
24372444
basis by sending a comma separated string parameter called infix to the search query.
24382445
This parameter can have 3 values; `off` infix search is disabled, which is default
2439-
`always` infix search is performed along with regular search
2440-
`fallback` infix search is performed if regular search does not produce results
2446+
`always` infix search is performed along with regular search
2447+
`fallback` infix search is performed if regular search does not produce results
24412448
type: string
24422449

24432450
max_extra_prefix:
@@ -2773,7 +2780,7 @@ components:
27732780
type: boolean
27742781
conversation_model_id:
27752782
description: >
2776-
The Id of Conversation Model to be used.
2783+
The Id of Conversation Model to be used.
27772784
type: string
27782785
conversation_id:
27792786
description: >
@@ -2821,8 +2828,8 @@ components:
28212828
If infix index is enabled for this field, infix searching can be done on a per-field
28222829
basis by sending a comma separated string parameter called infix to the search query.
28232830
This parameter can have 3 values; `off` infix search is disabled, which is default
2824-
`always` infix search is performed along with regular search
2825-
`fallback` infix search is performed if regular search does not produce results
2831+
`always` infix search is performed along with regular search
2832+
`fallback` infix search is performed if regular search does not produce results
28262833
type: string
28272834

28282835
max_extra_prefix:
@@ -3143,7 +3150,7 @@ components:
31433150
type: boolean
31443151
conversation_model_id:
31453152
description: >
3146-
The Id of Conversation Model to be used.
3153+
The Id of Conversation Model to be used.
31473154
type: string
31483155
conversation_id:
31493156
description: >

typesense/api/types_gen.go

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typesense/document.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import (
55
"encoding/json"
66
"io"
77
"strings"
8+
9+
"github.com/typesense/typesense-go/v2/typesense/api"
810
)
911

1012
type DocumentInterface[T any] interface {
1113
Retrieve(ctx context.Context) (T, error)
12-
Update(ctx context.Context, document any) (T, error)
14+
Update(ctx context.Context, document any, params *api.DocumentIndexParameters) (T, error)
1315
Delete(ctx context.Context) (T, error)
1416
}
1517

@@ -39,9 +41,9 @@ func (d *document[T]) Retrieve(ctx context.Context) (resp T, err error) {
3941
return resp, nil
4042
}
4143

42-
func (d *document[T]) Update(ctx context.Context, document any) (resp T, err error) {
44+
func (d *document[T]) Update(ctx context.Context, document any, params *api.DocumentIndexParameters) (resp T, err error) {
4345
response, err := d.apiClient.UpdateDocument(ctx,
44-
d.collectionName, d.documentID, document)
46+
d.collectionName, d.documentID, &api.UpdateDocumentParams{DirtyValues: params.DirtyValues}, document)
4547
if err != nil {
4648
return resp, err
4749
}

0 commit comments

Comments
 (0)