Skip to content

Conversation

@ben-kalmus
Copy link
Contributor

@ben-kalmus ben-kalmus commented Aug 28, 2025

🧭 What and Why

🎟 JIRA Ticket:

Changes included:

  • Add external injection search source
  • injectedItems can now either be a search or external source.
  • Add injectedItems compositions runtime parameter.

🧪 Test

CI

@algolia-bot
Copy link
Collaborator

algolia-bot commented Aug 28, 2025

✔️ Code generated!

Name Link
🪓 Triggered by 07c0b9dbc6e8c6e79f4859dbd414c7c8c8d566fe
🍃 Generated commit 90129e77ffb45ccdbf3dd6449c97e25c95fc568d
🌲 Generated branch generated/benk/compositions/external-source
📊 Benchmark results

Benchmarks performed on the method using a mock server, the results might not reflect the real-world performance.

Language Req/s
go 1752
php 1514
javascript 1445
csharp 1282
python 1143
java 1005
ruby 815
swift 400
scala 23

@ben-kalmus ben-kalmus force-pushed the benk/compositions/external-source branch 2 times, most recently from 3c21967 to 61a020b Compare August 29, 2025 09:04
@ben-kalmus ben-kalmus marked this pull request as ready for review August 29, 2025 10:00
@ben-kalmus ben-kalmus requested a review from a team as a code owner August 29, 2025 10:00
@ben-kalmus ben-kalmus requested review from a team, millotp and shortcuts August 29, 2025 10:00
Copy link
Contributor

@ClaraMuller ClaraMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment but first shot is super clean 👍

@ClaraMuller ClaraMuller requested a review from a team August 29, 2025 10:25
@ben-kalmus ben-kalmus force-pushed the benk/compositions/external-source branch from d443f32 to d58c58f Compare August 29, 2025 15:58
A list of injected objectIDs into an external source.
default: []
example:
[{'objectID': 'my-object-1', 'metadata': {'my-field': 'my-value'}}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you verified the generated examples look correct? Typically JSON requires " instead of '

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to generate examples

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't generate examples or tests from the specs, any test created in the CTS is then exposed a fully validated code snippet that can be exposed on the docs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can find the output here #5283 (comment) when the CI is done running, under the docs/snippets folder

required:
- search
description: Search source to be used to inject items into result set.
$ref: '#/injectionSource'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the previous name made it clear the type was only good for injectedItems. I think you could even keep it inline here since it can't be reused outside injectedItems

Suggested change
$ref: '#/injectionSource'
title: injectedItemSource
oneOf:
- $ref: './InjectionSource.yml#/search'
- $ref: './InjectionSource.yml#/external'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the name, but had to keep 'oneOf' statement as root component. It cannot be nested, as I'm getting an error:
56:5 error oneOf must be out of line automation-custom/out-of-line-one-of

Comment on lines 8 to 10
- type: object
additionalProperties: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this object w/ no properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped this

objectID:
type: string
metadata:
$ref: '../schemas/components/CompositionBehavior.yml#/metadata'
Copy link
Contributor

@gavinwade12 gavinwade12 Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This points to the entire metadata object, but it should really just be generic key-value pairs. I think technically something like this might work, but there's probably a better way

$ref: '../schemas/components/CompositionBehavior.yml#/metadata/properties/hits/properties/extra'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed reference

@ben-kalmus ben-kalmus force-pushed the benk/compositions/external-source branch from 866333f to 5c5302b Compare September 1, 2025 12:07
ClaraMuller
ClaraMuller previously approved these changes Sep 1, 2025
Copy link
Contributor

@ClaraMuller ClaraMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment but LGTM otherwise

@ben-kalmus ben-kalmus force-pushed the benk/compositions/external-source branch 3 times, most recently from dc532ae to d1d482f Compare September 1, 2025 16:58
@millotp
Copy link
Collaborator

millotp commented Sep 2, 2025

Hello, there is an issue with the CTS, I think you need to update the putComposition.json file:

Error in putComposition: Parameter 'search' not found in 'source'. Available properties are: index, params.

@ben-kalmus
Copy link
Contributor Author

Hello, there is an issue with the CTS, I think you need to update the putComposition.json file:

Error in putComposition: Parameter 'search' not found in 'source'. Available properties are: index, params.

I've fixed this, the error was a little deceptive because the issue was with injectedItemSource in CompositionBehavior.json. However, when I generate typescript locally, I don't quite see the result that I should expect. For example, in external.ts

import type { Search } from './search';

/**
 * Injected items will originate from externally provided objectIDs (that must exist in the index) given at runtime in the run request payload.
 */
export type External = Search;

The External type is just an alias for Search, however the External source should also have an additional field ordering | string.

@millotp
Copy link
Collaborator

millotp commented Sep 2, 2025

Unfortunately the generator does not support anonymous objects, because it's not possible to generate in all the languages that we support.
In this allOf, the ordering property should be defined in it's own object, with it's own title.
Then you can use it in the allOf like:

allOf:
  - $ref: '#/search'
  - $ref: '#/ordering'

@ben-kalmus
Copy link
Contributor Author

Unfortunately the generator does not support anonymous objects, because it's not possible to generate in all the languages that we support. In this allOf, the ordering property should be defined in it's own object, with it's own title. Then you can use it in the allOf like:

allOf:
  - $ref: '#/search'
  - $ref: '#/ordering'

That worked! Thank you.

@ben-kalmus ben-kalmus force-pushed the benk/compositions/external-source branch 2 times, most recently from 94b9ff7 to e0441d1 Compare September 2, 2025 13:11
@ben-kalmus ben-kalmus force-pushed the benk/compositions/external-source branch from 483c3dc to 9e65302 Compare September 2, 2025 15:13
Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the contribution !

@millotp millotp merged commit 646b7a5 into main Sep 2, 2025
29 checks passed
@millotp millotp deleted the benk/compositions/external-source branch September 2, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants