Skip to content

Commit

Permalink
term and alternative image url field
Browse files Browse the repository at this point in the history
  • Loading branch information
theorm committed Jan 17, 2025
1 parent 2daad3f commit d5ca242
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/models/generated/schemas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,10 @@ export interface Image {
* The unique identifier of the image
*/
uid: string;
/**
* Image caption
*/
caption?: string;
/**
* The unique identifier of the issue that the image belongs to.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/models/generated/schemasPublic.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ export interface Image {
* The unique identifier of the image
*/
uid: string;
/**
* Image caption
*/
caption?: string;
/**
* The unique identifier of the issue that the image belongs to.
*/
Expand Down
1 change: 1 addition & 0 deletions src/models/generated/solr.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface Image {
coords_is?: number[];
front_b?: boolean;
iiif_url_s?: string;
iiif_link_s?: string;
cc_b?: boolean;
rights_data_domain_s?: string;
rights_copyright_s?: string;
Expand Down
4 changes: 4 additions & 0 deletions src/schema/schemas/Image.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"type": "string",
"description": "The unique identifier of the image"
},
"caption": {
"type": "string",
"description": "Image caption"
},
"issueUid": {
"type": "string",
"description": "The unique identifier of the issue that the image belongs to."
Expand Down
4 changes: 4 additions & 0 deletions src/schema/schemasPublic/Image.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"type": "string",
"description": "The unique identifier of the image"
},
"caption": {
"type": "string",
"description": "Image caption"
},
"issueUid": {
"type": "string",
"description": "The unique identifier of the issue that the image belongs to."
Expand Down
1 change: 1 addition & 0 deletions src/schema/solr/Image.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"front_b": { "type": "boolean" },
"iiif_url_s": { "type": "string", "format": "uri" },
"iiif_link_s": { "type": "string", "format": "uri" },
"cc_b": { "type": "boolean" },
"rights_data_domain_s": { "type": "string" },
"rights_copyright_s": { "type": "string" },
Expand Down
8 changes: 7 additions & 1 deletion src/services/images/images.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const ImageSimilarityVectorField: keyof ImageDocument = 'dinov2_emb_v1024'

export interface FindQuery {
similar_to_image_id?: string
term?: string
limit?: number
offset?: number
}
Expand All @@ -24,6 +25,10 @@ export class Images implements Pick<ClientService<Image, unknown, unknown, Publi

const queryParts: string[] = []

if ((params?.query?.term?.length ?? 0) !== 0) {
queryParts.push(`caption_txt:${params?.query?.term}`)
}

if (params?.query?.similar_to_image_id) {
const referenceId = params.query.similar_to_image_id
const referenceImage = await this.getImageDocument(referenceId, [ImageSimilarityVectorField])
Expand Down Expand Up @@ -81,6 +86,7 @@ const toImage = (doc: ImageDocument): Image => {
uid: doc.id!,
...(doc.linked_ci_s != null ? { contentItemUid: doc.linked_ci_s } : {}),
issueUid: doc.meta_issue_id_s!,
previewUrl: doc.iiif_url_s!,
previewUrl: doc.iiif_url_s ?? doc.iiif_link_s!,
...(doc.caption_txt != null ? { caption: doc.caption_txt.join('\n') } : {}),
}
}
2 changes: 1 addition & 1 deletion src/services/images/images.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const similarToImageId: QueryParameter = {
}

const findParameters: MethodParameter[] = [
// parameterTerm,
parameterTerm,
similarToImageId,
...getStandardParameters({ method: 'find', maxPageSize: 100 }),
]
Expand Down

0 comments on commit d5ca242

Please sign in to comment.