Skip to content

IBX-9846: Describe Embeddings search API#3029

Open
dabrt wants to merge 16 commits into5.0from
IBX-9846
Open

IBX-9846: Describe Embeddings search API#3029
dabrt wants to merge 16 commits into5.0from
IBX-9846

Conversation

@dabrt
Copy link
Contributor

@dabrt dabrt commented Jan 30, 2026

Question Answer
JIRA Ticket IBX-9846
Versions 4.6, 5.0
Edition All

Describe Embeddings search API

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • PHP code samples have been fixed with PHP CS fixer
  • Added link to this PR in relevant JIRA ticket or code PR

@github-actions
Copy link

github-actions bot commented Jan 30, 2026

@dabrt dabrt requested a review from mikadamczyk February 26, 2026 14:09
dabrt and others added 2 commits February 27, 2026 16:01
Co-authored-by: Mikolaj Adamczyk <mikadamczyk@gmail.com>
@dabrt dabrt requested a review from mikadamczyk February 27, 2026 16:12
@mnocon mnocon requested a review from a team March 5, 2026 16:32
@dabrt dabrt requested a review from mnocon March 24, 2026 09:07
@github-actions
Copy link

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/api/public_php_api/src/Command/FindByTaxonomyEmbeddingCommand.php


code_samples/api/public_php_api/src/Command/FindByTaxonomyEmbeddingCommand.php

docs/search/search_api.md@395:``` php
docs/search/search_api.md@396:// ...
docs/search/search_api.md@397:[[= include_file('code_samples/api/public_php_api/src/Command/FindByTaxonomyEmbeddingCommand.php') =]]
docs/search/search_api.md@398:```

001⫶// ...
002⫶<?php
003⫶
004⫶declare(strict_types=1);
005⫶
006⫶namespace App\Command;
007⫶
008⫶use Ibexa\Contracts\Core\Repository\SearchService;
009⫶use Ibexa\Contracts\Core\Repository\Values\Content\EmbeddingQueryBuilder;
010⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentTypeIdentifier;
011⫶use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit;
012⫶use Ibexa\Contracts\Core\Search\Embedding\EmbeddingProviderResolverInterface;
013⫶use Ibexa\Contracts\Taxonomy\Search\Query\Value\TaxonomyEmbedding;
014⫶use Symfony\Component\Console\Attribute\AsCommand;
015⫶use Symfony\Component\Console\Command\Command;
016⫶use Symfony\Component\Console\Input\InputInterface;
017⫶use Symfony\Component\Console\Output\OutputInterface;
018⫶use Symfony\Component\Console\Style\SymfonyStyle;
019⫶
020⫶#[AsCommand(
021⫶ name: 'ibexa:taxonomy:find-by-embedding',
022⫶ description: 'Finds content using a taxonomy embedding query.'
023⫶)]
024⫶final class FindByTaxonomyEmbeddingCommand extends Command
025⫶{
026⫶ public function __construct(
027⫶ private readonly SearchService $searchService,
028⫶ private readonly EmbeddingProviderResolverInterface $embeddingProviderResolver,
029⫶ ) {
030⫶ parent::__construct();
031⫶ }
032⫶
033⫶ protected function execute(
034⫶ InputInterface $input,
035⫶ OutputInterface $output
036⫶ ): int {
037⫶ $io = new SymfonyStyle($input, $output);
038⫶
039⫶ $embeddingProvider = $this->embeddingProviderResolver->resolve();
040⫶ $embedding = $embeddingProvider->getEmbedding('example_content');
041⫶
042⫶ $query = EmbeddingQueryBuilder::create()
043⫶ ->withEmbedding(new TaxonomyEmbedding($embedding))
044⫶ ->setFilter(new ContentTypeIdentifier('article'))
045⫶ ->setLimit(10)
046⫶ ->setOffset(0)
047⫶ ->setPerformCount(true)
048⫶ ->build();
049⫶
050⫶ $result = $this->searchService->findContent($query);
051⫶
052⫶ $io->success(sprintf('Found %d items.', $result->totalCount));
053⫶
054⫶ foreach ($result->searchHits as $searchHit) {
055⫶ assert($searchHit instanceof SearchHit);
056⫶
057⫶ /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Content $content */
058⫶ $content = $searchHit->valueObject;
059⫶ $contentInfo = $content->versionInfo->contentInfo;
060⫶
061⫶ $io->writeln(sprintf(
062⫶ '%d: %s',
063⫶ $contentInfo->id,
064⫶ $contentInfo->name
065⫶ ));
066⫶ }
067⫶
068⫶ return self::SUCCESS;
069⫶ }
070⫶}


code_samples/api/public_php_api/src/embedding_fields.php


code_samples/api/public_php_api/src/embedding_fields.php

docs/search/embeddings_reference/embeddings_reference.md@90:``` php
docs/search/embeddings_reference/embeddings_reference.md@91:[[= include_file('code_samples/api/public_php_api/src/embedding_fields.php') =]]
docs/search/embeddings_reference/embeddings_reference.md@92:```

001⫶<?php declare(strict_types=1);
002⫶
003⫶// Create an embedding field using the default embedding provider (type derived from configuration's field suffix)
004⫶
005⫶/** @var Ibexa\Contracts\Core\Search\FieldType\EmbeddingFieldFactory $factory */
006⫶$embeddingField = $factory->create();
007⫶echo $embeddingField->getType(); // for example, "ibexa_dense_vector_model_123"
008⫶
009⫶// Create a custom embedding field with a specific type
010⫶$customField = $factory->create('custom_embedding_type');
011⫶echo $customField->getType(); // "custom_embedding_type"

Download colorized diff

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants