various fixes in SAI documentation and vector search documentation

patch by Stefan Miklosovic; reviewed by Lorina Poland, Michael Semb Wever for CASSANDRA-19030
This commit is contained in:
Stefan Miklosovic 2023-11-20 13:54:32 +01:00
parent 2004c17b60
commit bee4b187e7
No known key found for this signature in database
GPG Key ID: 32F35CB2F546D93E
23 changed files with 30 additions and 337 deletions

View File

@ -11,9 +11,8 @@ Use the `list` data type to store data that has a possible many-to-many relation
* xref:developing/cql/keyspace-check.adoc[Keyspace] must exist
In the following example, a `list` called `events` stores all the race events on an upcoming calendar.
The table is called `upcoming_calendar`.
Each event listed in the `list` will have a `text` data type.
In the following example, a `list` called `events` stores all the race events on an upcoming calendar.
The table is called `upcoming_calendar`. Each event listed in the `list` will have a `text` data type.
Events can have several events occurring in a particular month and year, so duplicates can occur.
The `list` can be ordered so that the races appear in the order that they will take place, rather than alphabetical order.

View File

@ -14,7 +14,7 @@ For that reason, when used in this document, these terms (tables, rows and colum
* xref:developing/cql/ddl.adoc[Data definition language]
* xref:developing/cql/dml.adoc[Data manipulation language]
* xref:developing/cql/operators.adoc[Operators]
* xref:cql/indexing/indexing-concepts.adoc[Indexing]
* xref:developing/cql/indexing/indexing-concepts.adoc[Indexing]
* xref:developing/cql/mvs.adoc[Materialized views]
* xref:developing/cql/functions.adoc[Functions]
* xref:developing/cql/json.adoc[JSON]

View File

@ -1,3 +1,4 @@
[[saiUsingCollectionsListExamples]]
= Using the list type
This example uses the following table and index:

View File

@ -6,7 +6,9 @@ This example uses the following table and indexes:
[source,sql]
----
include::cassandra:example$CQL/sai/cyclist_teams-table.cql[tag=mapColumn]
include::cassandra:example$CQL/sai/index-sai-from-map-match.cql[]
include::cassandra:example$CQL/sai/index-sai-from-map-match.cql[tag=keysidx]
include::cassandra:example$CQL/sai/index-sai-from-map-match.cql[tag=entriesidx]
include::cassandra:example$CQL/sai/index-sai-from-map-match.cql[tag=valuesidx]
----
Indexes created on the map column `teams` in the `cyclist_career_teams` table target the keys, values, and full entries of the column data.

View File

@ -1,3 +1,4 @@
[[saiUsingCollectionsSetExamples]]
= Using the set type
This example uses the following table and index:

View File

@ -53,4 +53,4 @@ SAI outperforms any other indexing method available for {product}.
SAI provides more functionality than secondary indexing (2i), using a fraction of the disk space, and reducing the total cost of ownership (TCO) for disk, infrastructure, and operations.
For read path performance, SAI performs at least as well as the other indexing methods for throughput and latency.
include::_sai-read-write-paths.adoc[leveloffset=+1]
include::sai-read-write-paths.adoc[leveloffset=+1]

View File

@ -38,7 +38,7 @@ If this occurs in your environment, increase `memtable_flush_writers`.
Aside from memory, SAI uses the same tunable parameters for Cassandra, such as compaction throughput and compaction executors.
This matters for write performance.
For read performance, again, maximizing use of the Chunk Cache will benefit SAI reads because all on-disk index components are accessed through this mechanism.
Refer to xref:cassandra:developing/cql/indexing/sai/configuring.adoc[Configure SAI indexes].
Refer to xref:cassandra:developing/cql/indexing/sai/operations/configuring.adoc[Configure SAI indexes].
== What computing challenges does SAI solve?
@ -94,10 +94,10 @@ USING 'StorageAttachedIndex'+` commands and `DROP INDEX` commands.
Start in xref:cassandra:getting-started/sai-quickstart.adoc[SAI quickstart].
* Rebuilt and backed up via nodetool.
See xref:cassandra:managing/tools/nodetool/toolsNodetool.html[nodetool].
See xref:managing/tools/nodetool/nodetool.adoc[nodetool].
* Monitored via a combination of nodetool, CQL virtual tables, system metrics, and JMX.
See xref:cassandra:developing/cql/indexing/sai/monitoring.adoc[Monitor SAI indexes].
See xref:developing/cql/indexing/sai/operations/monitoring.adoc[Monitor SAI indexes].
// LLP: There are currently no limits placed on SAI indexes in Apache C*.
// [[saiLimitsFaq]]
@ -129,12 +129,12 @@ include::cassandra:partial$sai/collections-note.adoc[]
include::cassandra:partial$sai/queryable-paragraph.adoc[]
--
See xref:cassandra:developing/cql/indexing/sai/monitoring.adoc#saiMonitorVirtualTables[Virtual tables] and xref:reference:system-virtual-tables/virtual-tables-sai-indexes.adoc[Virtual tables for SAI indexes and SSTables].
See xref:cassandra:developing/cql/indexing/sai/operations/monitoring.adoc#saiMonitorVirtualTables[Virtual tables] and xref:reference/sai-virtual-table-indexes.adoc[Virtual tables for SAI indexes and SSTables].
== What are the write and read paths used by SAI indexes?
SAI indexes Memtables and SSTables as they are written, resolving the differences between those indexes at read time.
See xref:cassandra:developing/cql/indexing/sai/read-write-paths.adoc[SAI write path and read path].
See xref:developing/cql/indexing/sai/sai-read-write-paths.adoc[SAI write path and read path].
== What on-disk index formats does SAI support?
@ -171,9 +171,7 @@ The supported types are: `ASCII, BIGINT, DATE, DECIMAL, DOUBLE, FLOAT, INET, INT
Yes -- SAI supports collections of type `map`, `list`, and `set`.
See the following topics:
* xref:cassandra:developing/cql/indexing/sai/collections.adoc#saiUsingCollections[Using collections with SAI]
* xref:cassandra:developing/cql/indexing/sai/collections.adoc#saiUsingCollectionsMapExamples[SAI collection map examples with keys, values, and entries]
* xref:cassandra:developing/cql/indexing/sai/collections.adoc#saiUsingCollectionsListAndSetExamples[SAI collection examples with list and set types]
* xref:cassandra:developing/cql/indexing/sai/collections.adoc[Using collections with SAI]
// * xref:reference:cql-commands/create-custom-index.adoc[CREATE CUSTOM INDEX]
include::cassandra:partial$sai/collections-note.adoc[]
@ -202,7 +200,7 @@ SELECT * FROM audit WHERE text_map CONTAINS KEY 'Giovani';
[TIP]
====
For query examples with `CONTAINS` clauses that take advantage of SAI collection maps, lists, and sets, be sure to see xref:cassandra:developing/cql/indexing/sai/collections.adoc#saiUsingCollectionsMapExamples[SAI collection map examples with keys, values, and entries] and xref:cassandra:developing/cql/indexing/sai/collections.adoc#saiUsingCollectionsListAndSetExamples[SAI collection examples with list and set types].
For query examples with `CONTAINS` clauses that take advantage of SAI collection maps, lists, and sets, be sure to see xref:developing/cql/indexing/sai/collections.adoc[SAI collection map examples with keys, values, and entries].
====
== On the `CREATE CUSTOM INDEX` command for SAI, what options are available?
@ -222,9 +220,9 @@ CREATE CUSTOM INDEX lastname_sai_idx ON cycling.cyclist_semi_pro (lastname)
SAI has an `ascii` option.
The default is `false`.
When set to `true`, SAI converts alphabetic, numeric, and symbolic characters that are not in the Basic Latin Unicode block (the first 127 ASCII characters) to the ASCII equivalent, if one exists.
For example, this option changes à to a.
For example, this option changes `à` to `a`.
See xref:reference:cql-commands/create-custom-index.adoc[CREATE CUSTOM INDEX] and examples in the xref:cassandra:getting-started/sai-quickstart.adoc[SAI quickstart] topic.
See xref:reference/cql-commands/create-custom-index.adoc[CREATE CUSTOM INDEX] and examples in the xref:cassandra:getting-started/sai-quickstart.adoc[SAI quickstart] topic.
====
== Does SAI support composite indexing: meaning, a single index on multiple columns?
@ -240,9 +238,9 @@ The SAI memory footprint is divided between the JVM heap and the Chunk Cache.
The heap stores memtable indexes, and the chunk cache stores recently accessed on-disk index components as well as other SSTable components.
SAI provides metrics for both the heap and the chunk cache.
For each index, SAI also provides metrics for determining the size in bytes of memory used by the on-disk data structure, as well as disk usage.
Refer to xref:cassandra:developing/cql/indexing/sai/monitoring.adoc#saiIndexGroupMetrics[Index group metrics].
Refer to xref:developing/cql/indexing/sai/operations/monitoring.adoc#saiIndexGroupMetrics[Index group metrics].
SAI also provides Table state metrics that give you visibility into the disk usage, the percentage of disk usage of the base table, the index builds in progress, and related metrics.
See xref:cassandra:developing/cql/indexing/sai/monitoring.adoc#saiTableStateMetrics[Table state metrics].
See xref:developing/cql/indexing/sai/operations/monitoring.adoc#saiTableStateMetrics[Table state metrics].
[[saiAndQueriesFaq]]
@ -261,7 +259,7 @@ In a query, AND queries will process up to two SAI indexes;
if more than two SAI indexes are used by the query, this circumstance will result in SAI performing post-filtering on the remaining clauses.
====
For related information, see the xref:cassandra:developing/cql/indexing/sai/read-write-paths.adoc#saiMatchStreamingAndPostFiltering[match streaming and post filtering] example.
For related information, see the xref:cassandra:developing/cql/indexing/sai/sai-read-write-paths.adoc#saiMatchStreamingAndPostFiltering[match streaming and post filtering] example.
[[saiWritesSyncFaq]]
== Are SAI write operations asynchronous, or does SAI wait before acknowledging the write to the user?
@ -271,7 +269,7 @@ The indexes live with the data, both in memtables and SSTables.
When a write is acknowledged to the client, the data is already indexed.
This is a *synchronous* process.
When the memtable is flushed, the indexes are flushed as well.
See xref:cassandra:developing/cql/indexing/sai/read-write-paths.adoc[SAI write path and read path].
See xref:developing/cql/indexing/sai/sai-read-write-paths.adoc[SAI write path and read path].
The on-disk index components are broken down into per-SSTable index files and per-column index files.
The column indexes do not store the primary keys or tokens;
@ -340,7 +338,7 @@ When you create an SAI index based on a string column, set the `normalize` optio
SAI supports Normalization Form C (NFC) Unicode.
When set to `true`, SAI normalizes the different versions of a given Unicode character to a single version, retaining all the marks and symbols in the index.
For example, SAI would change the character Å (U+212B) to Å (U+00C5).
See xref:reference:cql-commands/create-custom-index.adoc[CREATE CUSTOM INDEX].
See xref:reference/cql-commands/create-custom-index.adoc[CREATE CUSTOM INDEX].
== Can the index's column name have special characters?
@ -350,4 +348,4 @@ SAI returns `InvalidRequestException` if you try to define an index on a column
== What partitioner does SAI support?
SAI supports only the xref:cassandra:architecture/dbArch/archPartitioners.adoc[Murmur3Partitioner].
SAI supports only the `Murmur3Partitioner`.

View File

@ -35,4 +35,4 @@ include::_multiple-index-match-with-in.adoc[leveloffset=+1]
include::_user-defined-type-match.adoc[leveloffset=+1]
include::_collections.adoc[leveloffset=+1]
include::collections.adoc[leveloffset=+1]

View File

@ -13,4 +13,4 @@ include::_sai-alter.adoc[leveloffset=+1]
include::_sai-drop.adoc[leveloffset=+1]
include::_sai-query.adoc[leveloffset=+1]
include::sai-query.adoc[leveloffset=+1]

View File

@ -14,7 +14,7 @@ The examples in this quickstart topic show SAI indexes with non-partition key co
== Create a keyspace
In `cqlsh`, define the `cycling` xref:reference/cql-commands/create-keyspace.adoc[keyspace] to try the commands in a test environment:
In `cqlsh`, define the `cycling` keyspace to try the commands in a test environment:
[source,language-cql]
----
@ -23,7 +23,7 @@ include::cassandra:example$CQL/sai/create-vector-keyspace-cycling.cql[]
== Create a database table
Using `cqlsh` or the CQL Console, create a `cyclist_semi_pro` database xref:reference:cql-commands/create-table.adoc[table] in the `cycling` keyspace or the keyspace name of your choice:
Using `cqlsh` or the CQL Console, create a `cyclist_semi_pro` database xref:reference/cql-commands/create-table.adoc[table] in the `cycling` keyspace or the keyspace name of your choice:
[source,language-cql]
----
@ -179,7 +179,7 @@ include::cassandra:example$RESULTS/sai/cyclist_semi_pro_select_date_range.result
[TIP]
====
For query examples with `CONTAINS` clauses that take advantage of SAI collection maps, lists, and sets, be sure to see xref:developing/cql/indexing/sai/collections.adoc#saiUsingCollectionsMapExamples[SAI collection map examples with keys, values, and entries] and xref:developing/cql/indexing/sai/collections.adoc#saiUsingCollectionsListAndSetExamples[SAI collection examples with list and set types].
For query examples with `CONTAINS` clauses that take advantage of SAI collection maps, lists, and sets, be sure to see xref:developing/cql/indexing/sai/collections.adoc[SAI collection map examples with keys, values, and entries].
====
== Removing an SAI index

View File

@ -1,198 +0,0 @@
= SAI Quickstart
:description: Follow the steps to get started quickly with Storage-Attached Indexing (SAI).
To get started with Storage-Attached Indexing (SAI), we'll do the following steps:
* Create a keyspace.
* Create a table.
* Create an xref:reference:cql-commands/create-custom-index.adoc[index using SAI].
* Add data.
* Create and run a query using SAI.
The examples in this quickstart topic show SAI indexes with non-partition key columns.
// See the next topic, xref:developing/cql/indexing/sai/sai-query.adoc[Examine SAI column index and query rules], for examples that include indexing based on a single column from a composite partition key.
== Create a keyspace
In `cqlsh`, define the `cycling` xref:reference/cql-commands/create-keyspace.adoc[keyspace] to try the commands in a test environment:
[source,language-cql]
----
include::cassandra:example$CQL/0_create_keyspace.cql[tag=cyclingks]
----
== Create a database table
Using `cqlsh` or the CQL Console, create a `cyclist_semi_pro` database xref:reference:cql-commands/create-table.adoc[table] in the `cycling` keyspace or the keyspace name of your choice:
[source,language-cql]
----
include::cassandra:example$CQL/cyclist_semi_pro-table.cql[tag=createCyclistSemiProTable]
----
== Create SAI indexes on the database table
To test a non-trivial query, you'll need some SAI indexes.
Use xref:reference:cql-commands/create-custom-index.adoc[CREATE CUSTOM INDEX] commands to create SAI indexes on a few non-primary-key columns in the `cyclist_semi_pro` table:
[source,language-cql]
----
include::cassandra:example$CQL/cyclist_semi_pro_sai_indices.cql[tag=createQuickStartIndices]
----
Let's take a look at the description of the table and its indexes:
[tabs]
====
Query::
+
--
[source,language-cql]
----
DESCRIBE TABLE cycling.cyclist_semi_pro;
----
--
Result::
+
--
[source,language-cql]
----
include::cassandra:example$CQL/cyclist_semi_pro_describe.results[tag=cyclistSemiProDescribeResults]
----
--
====
== Add data to your table
Use CQLSH `INSERT` commands to add some data to the `cyclist_semi_pro` database table:
[source,language-cql]
----
include::cassandra:example$CQL/cyclist_semi_pro_inserts.cql[tag=createQuickStartIndices]
----
Adding data in this quickstart topic shows simple `INSERT` commands.
To load databases with many rows, consider using https://docs.datastax.com/en/dsbulk/doc/index.html[DataStax Bulk Loader for Apache Cassandra].
== Try out CQL queries
Use the CQLSH `SELECT` command to submit queries.
[TIP]
====
The supported query operators for tables with SAI indexes:
include::cassandra:partial$sai/supported-query-operators-list.adoc[]
include::cassandra:partial$sai/notSupportedOperators.adoc[]
====
Find a specific semi-pro cyclist:
[tabs]
====
Query::
+
--
[source,language-cql]
----
include::cassandra:example$CQL/cyclist_semi_pro_select_specific_rider.cql[tag=cyclistSelectSpecificRider]
----
--
Result::
+
--
[source, console]
----
include::cassandra:example$CQL/cyclist_semi_pro_select_specific_rider.results[tag=cyclistSelectSpecificRiderResults]
----
--
====
Find semi-pro cyclists whose age is less than or equal to 23:
[tabs]
====
Query::
+
--
[source,language-cql]
----
include::cassandra:example$CQL/cyclist_semi_pro_select_age.cql[tag=cyclistSelectAge]
----
--
Result::
+
--
[source,console]
----
include::cassandra:example$CQL/cyclist_semi_pro_select_age.results[tag=cyclistSelectAgeResults]
----
--
====
Find semi-pro cyclists from Great Britain:
[tabs]
====
Query::
+
--
[source,language-cql]
----
include::cassandra:example$CQL/cyclist_semi_pro_select_country.cql[tag=cyclistSelectCountry]
----
--
Result::
+
--
[source,console]
----
include::cassandra:example$CQL/cyclist_semi_pro_select_country.results[tag=cyclistSelectCountryResults]
----
--
====
Find semi-pro cyclists who registered between a given date range:
[tabs]
====
Query::
+
--
[source,language-cql]
----
include::cassandra:example$CQL/cyclist_semi_pro_select_date_range.cql[tag=cyclistSelectDateRange]
----
--
Result::
+
--
[source,results]
----
include::cassandra:example$CQL/cyclist_semi_pro_select_date_range.results[tag=cyclistSelectDateRangeResults]
----
--
====
[TIP]
====
For query examples with `CONTAINS` clauses that take advantage of SAI collection maps, lists, and sets, be sure to see xref:developing/cql/indexing/sai/collections.adoc#saiUsingCollectionsMapExamples[SAI collection map examples with keys, values, and entries] and xref:developing/cql/indexing/sai/collections.adoc#saiUsingCollectionsListAndSetExamples[SAI collection examples with list and set types].
====
== Removing an SAI index
To remove an SAI index, use `DROP INDEX`.
Example:
[source,language-cql]
----
DROP INDEX IF EXISTS cycling.age_sai_idx;
----
== What's next?
xref:developing/cql/indexing/sai/sai-query.adoc[Using SAI] examines column index and query rules, plus collection maps.

View File

@ -5,8 +5,5 @@ are supported with, and specific to:
* SAI *collection maps* with `keys`, `values`, and `entries`
* SAI *collections* with `list` and `set` types
For examples,
see xref:cassandra:developing/cql/indexing/sai/sai-query.adoc#saiUsingCollections[Using collections with SAI].
* SAI *collections* with `list` and `set` types
====

View File

@ -1,10 +0,0 @@
== Create vector search index
Create the custom index called `comment_vector` with Storage Attached Indexing (SAI):
[source,cql]
----
include::cassandra:example$CQL/create-vector-index-cycling.cql[]
----
For more about SAI, see the xref:developing:indexing/sai/sai-overview.adoc[Storage Attached Index] documentation.

View File

@ -1,8 +0,0 @@
== Create vector search keyspace
Create a new vector search keyspace called `cycling`:
[source,cql]
----
include::cassandra:getting-started/example$CQL/create-vector-keyspace-cycling.cql[]
----

View File

@ -1,16 +0,0 @@
== Create vector search table
Create a new table called `comments_vs` to store comments information:
[source,cql]
----
include::cassandra:getting-started/example$CQL/create-vector-table-cycling.cql[tag=createvstable]
----
Alternatively, if you didn't have a vector column in your original table, you could alter the original table to add a vector column `comment_vector` to store the embeddings:
[source,cql]
----
include::cassandra:getting-started/example$CQL/create-vector-table-cycling.cql[tag=altervstable]
----
<1> Notice that the vector uses the `float` data type and specifies the array dimension of 5 to store the embeddings.

View File

@ -1,10 +0,0 @@
== Load Vector Search data into your database
Insert data into the table:
[source,cql]
----
include::cassandra:getting-started/example$CQL/insert-vector-data-cycling.cql[]
----
Note the format of the new `vector` data type.

View File

@ -1,8 +0,0 @@
== Use vector search keyspace
Select the keyspace `cycling` for creating the vector search example:
[source,cql]
----
include::cassandra:getting-started/example$CQL/use-vector-keyspace-cycling.cql[]
----

View File

@ -1,6 +0,0 @@
. Create a new table in your keyspace, including the `item_vector` column for vector. The code below creates a vector with five values:
+
[source,cql]
----
include::cassandra:example$CQL/vector-search/create-vector-table-products.cql[]
----

View File

@ -1,8 +0,0 @@
== Load Vector Search data into your database
Insert data into the table using the new type:
[source,cql]
----
include::cassandra:example$CQL/vector-search/insert-vsearch-cycling.cql[]
----

View File

@ -1,33 +0,0 @@
== Query vector data with CQL
To query data using Vector Search, use a `SELECT` query:
[source,cql]
----
include::cassandra:example$CQL/vector-search/select-vsearch-cycling.cql[]
----
To obtain the distance calculation of the best scoring node closest to the query data as part of the results, use a `SELECT` query:
[source,cql]
----
include::cassandra:example$CQL/vector-search/select-vsearch-distance.cql[]
----
The supported functions for this type of query are:
* similarity_dot_product
* similarity_cosine
* similarity_euclidean
with the parameters of (<vector_column>, <embedding_value>).
Both parameters represent vectors.
[NOTE]
====
* The limit must be 1,000 or fewer.
* Vector Search utilizes Approximate Nearest Neighbor (ANN) that in most cases yields results almost as good as the exact match. The scaling is superior to Exact Nearest Neighbor (KNN).
* Least-similar searches are not supported.
* Vector Search works optimally on tables with no overwrites or deletions of the `item_vector` column. For an `item_vector` column with changes, expect slower search results.
====

View File

@ -1,8 +0,0 @@
== Create vector schema
. Select the keyspace you want to use for your Vector Search table. This example uses `cycling` as the `keyspace name`:
+
[source,cql]
----
include::cassandra:example$CQL/vector-search/use-keyspace-cycling.cql[]
----