File tree Expand file tree Collapse file tree
services/experiments/experiments Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { SolrNamespaces } from '../../../solr'
2+ import { ImpressoApplication } from '../../../types'
3+ import { ExperimentBase } from './base'
4+
5+ interface RequestBody {
6+ solrPayload : Record < string , any >
7+ }
8+
9+ interface ResponseBody {
10+ solrResponse : Record < string , any >
11+ }
12+
13+ export class EntityProfilesExperiment implements ExperimentBase < RequestBody , ResponseBody > {
14+ id = 'entity-profiles'
15+ name = 'Experiment with entity profiles and their embeddings'
16+ description = `
17+ Generates embeddings for subdocuments using a specified model.
18+ The body must contain a 'solrPayload' field with a
19+ JSON API Solr query (see https://solr.apache.org/guide/solr/latest/query-guide/json-request-api.html).
20+ `
21+
22+ async execute ( body : RequestBody , app : ImpressoApplication ) : Promise < ResponseBody > {
23+ if ( body . solrPayload == null ) {
24+ throw new Error ( "Request body must contain a 'solrPayload' field with a Solr JSON API query." )
25+ }
26+ const solrResponse = await app . service ( 'simpleSolrClient' ) . select ( SolrNamespaces . EntityProfiles , {
27+ body : body . solrPayload as any ,
28+ } )
29+ return {
30+ solrResponse,
31+ }
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ import { EntityProfilesExperiment } from './entityProfiles'
12import { SubdocEmbeddingsExperiment } from './subdocEmbeddings'
23
3- export const experiments = [ new SubdocEmbeddingsExperiment ( ) ]
4+ export const experiments = [ new SubdocEmbeddingsExperiment ( ) , new EntityProfilesExperiment ( ) ]
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export type SolrNamespace =
1616 | 'entities_mentions'
1717 | 'collection_items'
1818 | 'subdoc_embeddings_experiment'
19+ | 'entity_profiles'
1920
2021export const SolrNamespaces = Object . freeze ( {
2122 Search : 'search' ,
@@ -32,6 +33,7 @@ export const SolrNamespaces = Object.freeze({
3233 EntitiesMentions : 'entities_mentions' ,
3334 CollectionItems : 'collection_items' ,
3435 SubdocEmbeddingsExperiment : 'subdoc_embeddings_experiment' ,
36+ EntityProfiles : 'entity_profiles' ,
3537} ) satisfies Record < string , SolrNamespace >
3638
3739/**
You can’t perform that action at this time.
0 commit comments