Skip to content

Commit

Permalink
add is_tenant to multitenancy docs (#1076)
Browse files Browse the repository at this point in the history
* add is_tenant to multitenancy docs

* fix alert

* fix alert

* update python snippet
  • Loading branch information
generall authored Aug 12, 2024
1 parent 217c5ae commit 6f139ca
Showing 1 changed file with 63 additions and 13 deletions.
76 changes: 63 additions & 13 deletions qdrant-landing/content/documentation/guides/multiple-partitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,55 +404,89 @@ await client.CreateCollectionAsync(

3. Create keyword payload index for `group_id` field.

<aside role="alert">
<code>is_tenant</code> parameter is available as of v1.11.0. Previous versions should use default options for keyword index creation.
</aside>


```http
PUT /collections/{collection_name}/index
{
"field_name": "group_id",
"field_schema": "keyword"
"field_schema": {
"type": "keyword",
"is_tenant": true
}
}
```

```python
client.create_payload_index(
collection_name="{collection_name}",
field_name="group_id",
field_schema=models.PayloadSchemaType.KEYWORD,
field_schema=models.KeywordIndexParams(
type="keywprd",
is_tenant=True,
),
)
```

```typescript
client.createPayloadIndex("{collection_name}", {
field_name: "group_id",
field_schema: "keyword",
field_schema: {
type: "keyword",
is_tenant: true,
},
});
```

```rust
use qdrant_client::qdrant::{CreateFieldIndexCollectionBuilder, FieldType};
use qdrant_client::qdrant::{
CreateFieldIndexCollectionBuilder,
KeywordIndexParamsBuilder,
FieldType
};
use qdrant_client::{Qdrant, QdrantError};

let client = Qdrant::from_url("http://localhost:6334").build()?;

client
.create_field_index(CreateFieldIndexCollectionBuilder::new(
"{collection_name}",
"group_id",
FieldType::Keyword,
))
.await?;
client.create_field_index(
CreateFieldIndexCollectionBuilder::new(
"{collection_name}",
"group_id",
FieldType::Keyword,
).field_index_params(
KeywordIndexParamsBuilder::default()
.is_tenant(true)
)
).await?;
```

```java
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.PayloadIndexParams;
import io.qdrant.client.grpc.Collections.PayloadSchemaType;
import io.qdrant.client.grpc.Collections.KeywordIndexParams;

QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());

client
.createPayloadIndexAsync(
"{collection_name}", "group_id", PayloadSchsemaType.Keyword, null, null, null, null)
"{collection_name}",
"group_id",
PayloadSchemaType.Keyword,
PayloadIndexParams.newBuilder()
.setKeywordIndexParams(
KeywordIndexParams.newBuilder()
.setIsTenant(true)
.build())
.build(),
null,
null,
null)
.get();
```

Expand All @@ -461,9 +495,25 @@ using Qdrant.Client;

var client = new QdrantClient("localhost", 6334);

await client.CreatePayloadIndexAsync(collectionName: "{collection_name}", fieldName: "group_id");
await client.CreatePayloadIndexAsync(
collectionName: "{collection_name}",
fieldName: "group_id",
schemaType: PayloadSchemaType.Keyword,
indexParams: new PayloadIndexParams
{
KeywordIndexParams = new KeywordIndexParams
{
IsTenant = true
}
}
);

```

`is_tenant=true` parameter is optional, but specifying it provides storage with additional inforamtion about the usage patterns the collection is going to use.
When specified, storage structure will be organized in a way to co-locate vectors of the same tenant together, which can significantly improve performance in some cases.


## Limitations

One downside to this approach is that global requests (without the `group_id` filter) will be slower since they will necessitate scanning all groups to identify the nearest neighbors.

0 comments on commit 6f139ca

Please sign in to comment.