Skip to content

Commit 61d5ea6

Browse files
committed
search, video, websearch
1 parent 375772e commit 61d5ea6

File tree

19 files changed

+212
-274
lines changed

19 files changed

+212
-274
lines changed

graph/arangodb/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ generate_unused_types = true
3838
"golem:graph/[email protected]" = "golem_graph::golem::graph::types"
3939
"golem:graph/[email protected]" = "golem_graph::golem::graph::connection"
4040
"golem:graph/[email protected]" = "golem_graph::golem::graph::transactions"
41-
"golem:graph/[email protected]" = "golem_graph::golem::graph::traversal"
4241
"golem:graph/[email protected]" = "golem_graph::golem::graph::schema"
43-
"golem:graph/[email protected]" = "golem_graph::golem::graph::query"
44-
4542

4643
[package.metadata.component.target]
4744
path = "wit"

graph/janusgraph/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ generate_unused_types = true
3939
"golem:graph/[email protected]" = "golem_graph::golem::graph::types"
4040
"golem:graph/[email protected]" = "golem_graph::golem::graph::connection"
4141
"golem:graph/[email protected]" = "golem_graph::golem::graph::transactions"
42-
"golem:graph/[email protected]" = "golem_graph::golem::graph::traversal"
4342
"golem:graph/[email protected]" = "golem_graph::golem::graph::schema"
44-
"golem:graph/[email protected]" = "golem_graph::golem::graph::query"
4543

4644

4745
[package.metadata.component.target]

graph/neo4j/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ generate_unused_types = true
3838
"golem:graph/[email protected]" = "golem_graph::golem::graph::types"
3939
"golem:graph/[email protected]" = "golem_graph::golem::graph::connection"
4040
"golem:graph/[email protected]" = "golem_graph::golem::graph::transactions"
41-
"golem:graph/[email protected]" = "golem_graph::golem::graph::traversal"
4241
"golem:graph/[email protected]" = "golem_graph::golem::graph::schema"
43-
"golem:graph/[email protected]" = "golem_graph::golem::graph::query"
44-
4542

4643
[package.metadata.component.target]
4744
path = "wit"

search/algolia/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use crate::conversions::{
77
use golem_rust::wasm_rpc::Pollable;
88
use golem_search::config::with_config_keys;
99
use golem_search::durability::{DurableSearch, ExtendedGuest};
10-
use golem_search::golem::search::core::{Guest, GuestSearchStream, SearchStream};
10+
use golem_search::golem::search::core::{
11+
CreateIndexOptions, Guest, GuestSearchStream, SearchStream,
12+
};
1113
use golem_search::golem::search::types::{
1214
Doc, DocumentId, IndexName, Schema, SearchError, SearchHit, SearchQuery, SearchResults,
1315
};
@@ -117,7 +119,7 @@ impl AlgoliaComponent {
117119
impl Guest for AlgoliaComponent {
118120
type SearchStream = AlgoliaSearchStream;
119121

120-
fn create_index(_name: IndexName, _schema: Option<Schema>) -> Result<(), SearchError> {
122+
fn create_index(_options: CreateIndexOptions) -> Result<(), SearchError> {
121123
// Algolia doesn't require explicit index creation - indices are created automatically
122124
// when you first add documents.
123125
// providers that don't support index creation should return unsupported.

search/elasticsearch/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use crate::conversions::{
88
use golem_rust::wasm_rpc::Pollable;
99
use golem_search::config::with_config_keys;
1010
use golem_search::durability::{DurableSearch, ExtendedGuest};
11-
use golem_search::golem::search::core::{Guest, GuestSearchStream, SearchStream};
11+
use golem_search::golem::search::core::{
12+
CreateIndexOptions, Guest, GuestSearchStream, SearchStream,
13+
};
1214
use golem_search::golem::search::types::{
1315
Doc, DocumentId, IndexName, Schema, SearchError, SearchHit, SearchQuery, SearchResults,
1416
};
@@ -229,11 +231,11 @@ impl ElasticsearchComponent {
229231
impl Guest for ElasticsearchComponent {
230232
type SearchStream = ElasticsearchSearchStream;
231233

232-
fn create_index(name: IndexName, schema: Option<Schema>) -> Result<(), SearchError> {
234+
fn create_index(options: CreateIndexOptions) -> Result<(), SearchError> {
233235
let client = Self::create_client()?;
234-
let settings = schema.map(schema_to_elasticsearch_settings);
236+
let settings = options.schema.map(schema_to_elasticsearch_settings);
235237

236-
client.create_index(&name, settings)
238+
client.create_index(&options.index_name, settings)
237239
}
238240

239241
fn delete_index(name: IndexName) -> Result<(), SearchError> {

search/meilisearch/src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use crate::conversions::{
77
use golem_rust::wasm_rpc::Pollable;
88
use golem_search::config::with_config_keys;
99
use golem_search::durability::{DurableSearch, ExtendedGuest};
10-
use golem_search::golem::search::core::{Guest, GuestSearchStream, SearchStream};
10+
use golem_search::golem::search::core::{
11+
CreateIndexOptions, Guest, GuestSearchStream, SearchStream,
12+
};
1113
use golem_search::golem::search::types::{
1214
Doc, DocumentId, IndexName, Schema, SearchError, SearchHit, SearchQuery, SearchResults,
1315
};
@@ -126,21 +128,21 @@ impl MeilisearchComponent {
126128
impl Guest for MeilisearchComponent {
127129
type SearchStream = MeilisearchSearchStream;
128130

129-
fn create_index(name: IndexName, schema: Option<Schema>) -> Result<(), SearchError> {
131+
fn create_index(options: CreateIndexOptions) -> Result<(), SearchError> {
130132
let client = Self::create_client()?;
131133

132134
let create_request = client::MeilisearchCreateIndexRequest {
133-
uid: name.clone(),
135+
uid: options.index_name.clone(),
134136
primary_key: Some("id".to_string()), // Default primary key
135137
};
136138

137139
let task = client.create_index(&create_request)?;
138140

139141
client.wait_for_task(task.task_uid)?;
140142

141-
if let Some(schema) = schema {
143+
if let Some(schema) = options.schema {
142144
let settings = schema_to_meilisearch_settings(schema);
143-
let settings_task = client.update_settings(&name, &settings)?;
145+
let settings_task = client.update_settings(&options.index_name, &settings)?;
144146
client.wait_for_task(settings_task.task_uid)?;
145147
}
146148

search/opensearch/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use crate::conversions::{
88
use golem_rust::wasm_rpc::Pollable;
99
use golem_search::config::with_config_keys;
1010
use golem_search::durability::{DurableSearch, ExtendedGuest};
11-
use golem_search::golem::search::core::{Guest, GuestSearchStream, SearchStream};
11+
use golem_search::golem::search::core::{
12+
CreateIndexOptions, Guest, GuestSearchStream, SearchStream,
13+
};
1214
use golem_search::golem::search::types::{
1315
Doc, DocumentId, IndexName, Schema, SearchError, SearchHit, SearchQuery, SearchResults,
1416
};
@@ -189,11 +191,11 @@ impl OpenSearchComponent {
189191
impl Guest for OpenSearchComponent {
190192
type SearchStream = OpenSearchSearchStream;
191193

192-
fn create_index(name: IndexName, schema: Option<Schema>) -> Result<(), SearchError> {
194+
fn create_index(options: CreateIndexOptions) -> Result<(), SearchError> {
193195
let client = Self::create_client()?;
194196

195-
let settings = schema.map(schema_to_opensearch_settings);
196-
client.create_index(&name, settings)?;
197+
let settings = options.schema.map(schema_to_opensearch_settings);
198+
client.create_index(&options.index_name, settings)?;
197199

198200
Ok(())
199201
}

search/search/src/durability.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,17 @@ mod passthrough_impl {
3636
use crate::durability::{DurableSearch, ExtendedGuest};
3737
use crate::golem::search::core::{Guest, SearchStream};
3838
use crate::golem::search::types::{
39-
Doc, DocumentId, IndexName, Schema, SearchError, SearchQuery, SearchResults,
39+
CreateIndexOptions, Doc, DocumentId, IndexName, Schema, SearchError, SearchQuery,
40+
SearchResults,
4041
};
4142
use crate::init_logging;
4243

4344
impl<Impl: ExtendedGuest> Guest for DurableSearch<Impl> {
4445
type SearchStream = Impl::SearchStream;
4546

46-
fn create_index(name: IndexName, schema: Option<Schema>) -> Result<(), SearchError> {
47+
fn create_index(options: CreateIndexOptions) -> Result<(), SearchError> {
4748
init_logging();
48-
Impl::create_index(name, schema)
49+
Impl::create_index(options)
4950
}
5051

5152
fn delete_index(name: IndexName) -> Result<(), SearchError> {
@@ -111,7 +112,7 @@ mod passthrough_impl {
111112
#[cfg(feature = "durability")]
112113
mod durable_impl {
113114
use crate::durability::{DurableSearch, ExtendedGuest};
114-
use crate::golem::search::core::{Guest, GuestSearchStream, SearchStream};
115+
use crate::golem::search::core::{CreateIndexOptions, Guest, GuestSearchStream, SearchStream};
115116
use crate::golem::search::types::{
116117
Doc, DocumentId, IndexName, Schema, SearchError, SearchHit, SearchQuery, SearchResults,
117118
};
@@ -125,12 +126,6 @@ mod durable_impl {
125126
use std::cell::RefCell;
126127
use std::fmt::{Display, Formatter};
127128

128-
#[derive(Debug, Clone, IntoValue)]
129-
struct CreateIndexInput {
130-
name: IndexName,
131-
schema: Option<Schema>,
132-
}
133-
134129
#[derive(Debug, Clone, IntoValue)]
135130
struct DeleteIndexInput {
136131
name: IndexName,
@@ -227,7 +222,7 @@ mod durable_impl {
227222
impl<Impl: ExtendedGuest> Guest for DurableSearch<Impl> {
228223
type SearchStream = DurableSearchStream<Impl>;
229224

230-
fn create_index(name: IndexName, schema: Option<Schema>) -> Result<(), SearchError> {
225+
fn create_index(options: CreateIndexOptions) -> Result<(), SearchError> {
231226
init_logging();
232227

233228
let durability = Durability::<NoOutput, SearchError>::new(
@@ -237,11 +232,9 @@ mod durable_impl {
237232
);
238233
if durability.is_live() {
239234
let result = with_persistence_level(PersistenceLevel::PersistNothing, || {
240-
Impl::create_index(name.clone(), schema.clone()).map(|()| NoOutput)
235+
Impl::create_index(options.clone()).map(|()| NoOutput)
241236
});
242-
durability
243-
.persist(CreateIndexInput { name, schema }, result)
244-
.map(|_: NoOutput| ())
237+
durability.persist(options, result).map(|_: NoOutput| ())
245238
} else {
246239
durability.replay().map(|_: NoOutput| ())
247240
}

search/typesense/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use crate::conversions::*;
33
use golem_rust::wasm_rpc::Pollable;
44
use golem_search::config::with_config_keys;
55
use golem_search::durability::{DurableSearch, ExtendedGuest};
6-
use golem_search::golem::search::core::{Guest, GuestSearchStream, SearchStream};
6+
use golem_search::golem::search::core::{
7+
CreateIndexOptions, Guest, GuestSearchStream, SearchStream,
8+
};
79
use golem_search::golem::search::types::{
810
Doc, DocumentId, IndexName, Schema, SearchError, SearchHit, SearchQuery, SearchResults,
911
};
@@ -114,13 +116,14 @@ impl GuestSearchStream for TypesenseSearchStream {
114116
impl Guest for TypesenseComponent {
115117
type SearchStream = TypesenseSearchStream;
116118

117-
fn create_index(name: IndexName, schema: Option<Schema>) -> Result<(), SearchError> {
119+
fn create_index(options: CreateIndexOptions) -> Result<(), SearchError> {
118120
let client = Self::create_client()?;
119121

120-
let typesense_schema = schema
121-
.map(|s| schema_to_typesense_schema(s, &name))
122+
let typesense_schema = options
123+
.schema
124+
.map(|s| schema_to_typesense_schema(s, &options.index_name))
122125
.unwrap_or_else(|| CollectionSchema {
123-
name: name.clone(),
126+
name: options.index_name.clone(),
124127
fields: vec![CollectionField {
125128
name: "id".to_string(),
126129
field_type: "string".to_string(),
@@ -135,7 +138,7 @@ impl Guest for TypesenseComponent {
135138
symbols_to_index: None,
136139
});
137140

138-
client.create_collection(&name, &typesense_schema)?;
141+
client.create_collection(&options.index_name, &typesense_schema)?;
139142
Ok(())
140143
}
141144

search/wit/golem-search.wit

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,23 @@ interface types {
9999
fields: list<schema-field>,
100100
primary-key: option<string>,
101101
}
102+
103+
record create-index-options {
104+
index-name: string,
105+
schema: option<schema>
106+
}
102107
}
103108

104109
/// Unified search interface
105110
interface core {
106111
use types.{
107112
index-name, document-id, doc, search-query, search-results,
108-
search-hit, schema, search-error
113+
search-hit, schema, search-error,
114+
create-index-options
109115
};
110116

111117
// Index lifecycle
112-
create-index: func(name: index-name, schema: option<schema>) -> result<_, search-error>;
118+
create-index: func(options: create-index-options) -> result<_, search-error>;
113119
delete-index: func(name: index-name) -> result<_, search-error>;
114120
list-indexes: func() -> result<list<index-name>, search-error>;
115121

0 commit comments

Comments
 (0)