Skip to content

Commit

Permalink
CAMEL-21596 : Camel Qdrant: Add similariry search feature (#16732)
Browse files Browse the repository at this point in the history
  • Loading branch information
zbendhiba authored Jan 8, 2025
1 parent 95f04de commit df3d8ba
Show file tree
Hide file tree
Showing 12 changed files with 324 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
"configuration": { "index": 1, "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.qdrant.QdrantConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "The configuration;" },
"host": { "index": 2, "kind": "property", "displayName": "Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "localhost", "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "The host to connect to." },
"lazyStartProducer": { "index": 3, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." },
"port": { "index": 4, "kind": "property", "displayName": "Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 6334, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "The port to connect to." },
"timeout": { "index": 5, "kind": "property", "displayName": "Timeout", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "java.time.Duration", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "Sets a default timeout for all requests" },
"tls": { "index": 6, "kind": "property", "displayName": "Tls", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "Whether the client uses Transport Layer Security (TLS) to secure communications" },
"autowiredEnabled": { "index": 7, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }
"maxResults": { "index": 4, "kind": "property", "displayName": "Max Results", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 3, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "Max results for similarity search" },
"port": { "index": 5, "kind": "property", "displayName": "Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 6334, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "The port to connect to." },
"timeout": { "index": 6, "kind": "property", "displayName": "Timeout", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "java.time.Duration", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "Sets a default timeout for all requests" },
"tls": { "index": 7, "kind": "property", "displayName": "Tls", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "Whether the client uses Transport Layer Security (TLS) to secure communications" },
"autowiredEnabled": { "index": 8, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." },
"filter": { "index": 9, "kind": "property", "displayName": "Filter", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "io.qdrant.client.grpc.Points.Filter", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "Filter of type io.qdrant.client.grpc.Points.Points.Filter for similarity search. This is for advanced usage." }
},
"headers": {
"CamelQdrantAction": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "enum": [ "CREATE_COLLECTION", "DELETE_COLLECTION", "UPSERT", "RETRIEVE", "DELETE", "COLLECTION_INFO" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The action to be performed.", "constantName": "org.apache.camel.component.qdrant.Qdrant$Headers#ACTION" },
Expand All @@ -49,9 +51,11 @@
"collection": { "index": 0, "kind": "path", "displayName": "Collection", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The collection Name" },
"apiKey": { "index": 1, "kind": "parameter", "displayName": "Api Key", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "Sets the API key to use for authentication" },
"host": { "index": 2, "kind": "parameter", "displayName": "Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "localhost", "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "The host to connect to." },
"port": { "index": 3, "kind": "parameter", "displayName": "Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 6334, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "The port to connect to." },
"timeout": { "index": 4, "kind": "parameter", "displayName": "Timeout", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "java.time.Duration", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "Sets a default timeout for all requests" },
"tls": { "index": 5, "kind": "parameter", "displayName": "Tls", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "Whether the client uses Transport Layer Security (TLS) to secure communications" },
"lazyStartProducer": { "index": 6, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }
"maxResults": { "index": 3, "kind": "parameter", "displayName": "Max Results", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 3, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "Max results for similarity search" },
"port": { "index": 4, "kind": "parameter", "displayName": "Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 6334, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "The port to connect to." },
"timeout": { "index": 5, "kind": "parameter", "displayName": "Timeout", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "java.time.Duration", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "Sets a default timeout for all requests" },
"tls": { "index": 6, "kind": "parameter", "displayName": "Tls", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "Whether the client uses Transport Layer Security (TLS) to secure communications" },
"lazyStartProducer": { "index": 7, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." },
"filter": { "index": 8, "kind": "parameter", "displayName": "Filter", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "io.qdrant.client.grpc.Points.Filter", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.qdrant.QdrantConfiguration", "configurationField": "configuration", "description": "Filter of type io.qdrant.client.grpc.Points.Points.Filter for similarity search. This is for advanced usage." }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,24 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
case "autowiredenabled":
case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.qdrant.QdrantConfiguration.class, value)); return true;
case "filter": getOrCreateConfiguration(target).setFilter(property(camelContext, io.qdrant.client.grpc.Points.Filter.class, value)); return true;
case "host": getOrCreateConfiguration(target).setHost(property(camelContext, java.lang.String.class, value)); return true;
case "lazystartproducer":
case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
case "maxresults":
case "maxResults": getOrCreateConfiguration(target).setMaxResults(property(camelContext, int.class, value)); return true;
case "port": getOrCreateConfiguration(target).setPort(property(camelContext, int.class, value)); return true;
case "timeout": getOrCreateConfiguration(target).setTimeout(property(camelContext, java.time.Duration.class, value)); return true;
case "tls": getOrCreateConfiguration(target).setTls(property(camelContext, boolean.class, value)); return true;
default: return false;
}
}

@Override
public String[] getAutowiredNames() {
return new String[]{"filter"};
}

@Override
public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
Expand All @@ -53,9 +61,12 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
case "autowiredenabled":
case "autowiredEnabled": return boolean.class;
case "configuration": return org.apache.camel.component.qdrant.QdrantConfiguration.class;
case "filter": return io.qdrant.client.grpc.Points.Filter.class;
case "host": return java.lang.String.class;
case "lazystartproducer":
case "lazyStartProducer": return boolean.class;
case "maxresults":
case "maxResults": return int.class;
case "port": return int.class;
case "timeout": return java.time.Duration.class;
case "tls": return boolean.class;
Expand All @@ -72,9 +83,12 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
case "autowiredenabled":
case "autowiredEnabled": return target.isAutowiredEnabled();
case "configuration": return target.getConfiguration();
case "filter": return getOrCreateConfiguration(target).getFilter();
case "host": return getOrCreateConfiguration(target).getHost();
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
case "maxresults":
case "maxResults": return getOrCreateConfiguration(target).getMaxResults();
case "port": return getOrCreateConfiguration(target).getPort();
case "timeout": return getOrCreateConfiguration(target).getTimeout();
case "tls": return getOrCreateConfiguration(target).isTls();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
case "apikey":
case "apiKey": target.setApiKey(property(camelContext, java.lang.String.class, value)); return true;
case "client": target.setClient(property(camelContext, io.qdrant.client.QdrantClient.class, value)); return true;
case "filter": target.setFilter(property(camelContext, io.qdrant.client.grpc.Points.Filter.class, value)); return true;
case "host": target.setHost(property(camelContext, java.lang.String.class, value)); return true;
case "maxresults":
case "maxResults": target.setMaxResults(property(camelContext, int.class, value)); return true;
case "port": target.setPort(property(camelContext, int.class, value)); return true;
case "timeout": target.setTimeout(property(camelContext, java.time.Duration.class, value)); return true;
case "tls": target.setTls(property(camelContext, boolean.class, value)); return true;
Expand All @@ -40,7 +43,10 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
case "apikey":
case "apiKey": return java.lang.String.class;
case "client": return io.qdrant.client.QdrantClient.class;
case "filter": return io.qdrant.client.grpc.Points.Filter.class;
case "host": return java.lang.String.class;
case "maxresults":
case "maxResults": return int.class;
case "port": return int.class;
case "timeout": return java.time.Duration.class;
case "tls": return boolean.class;
Expand All @@ -55,7 +61,10 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
case "apikey":
case "apiKey": return target.getApiKey();
case "client": return target.getClient();
case "filter": return target.getFilter();
case "host": return target.getHost();
case "maxresults":
case "maxResults": return target.getMaxResults();
case "port": return target.getPort();
case "timeout": return target.getTimeout();
case "tls": return target.isTls();
Expand Down
Loading

0 comments on commit df3d8ba

Please sign in to comment.