Projections for collections
You can use a projection with many Data API commands to control what fields to include in the returned documents.
If you don’t specify a projection, the Data API returns the _id
field and all fields that are not prefixed with $
.
In order to optimize the response size and improve read performance, DataStax recommends always providing a projection tailored to the needs of the application.
When you specify a projection, you specify which fields to include or exclude.
You can’t specify a mix of inclusions and exclusions unless the field is _id
or is prefixed with $
.
If a projection includes fields that don’t exist in a returned document, then those fields are ignored for that document.
Include specific fields
The following examples include the is_checked_out
and title
fields.
_id
is included by default.
-
Python
-
TypeScript
-
Java
-
curl
You can use a dictionary or an iterable of field names to include.
Example using a dictionary:
from astrapy import DataAPIClient
# Get an existing collection
client = DataAPIClient()
database = client.get_database(
"API_ENDPOINT",
token="APPLICATION_TOKEN",
)
collection = database.get_collection("COLLECTION_NAME")
# Use a projection
cursor = collection.find(
{"metadata.language": "English"},
projection={"is_checked_out": True, "title": True},
)
Example using an iterable:
from astrapy import DataAPIClient
# Get an existing collection
client = DataAPIClient()
database = client.get_database(
"API_ENDPOINT",
token="APPLICATION_TOKEN",
)
collection = database.get_collection("COLLECTION_NAME")
# Use a projection
cursor = collection.find(
{"metadata.language": "English"},
projection=["is_checked_out", "title"],
)
The TypeScript client takes in an untyped Plain Old JavaScript Object (POJO) for the projection
parameter.
Consider type-casting to help you handle the return type.
You can use any truthy value in the projection.
This example uses true
.
import { DataAPIClient } from '@datastax/astra-db-ts';
// Get an existing collection
const client = new DataAPIClient('APPLICATION_TOKEN');
const database = client.db('API_ENDPOINT');
const collection = database.collection('COLLECTION_NAME');
const cursor = collection.find(
{ "metadata.language": "English" },
{ projection: { is_checked_out: true, title: true} },
);
Java client has different Options
classes that provide a projection
method.
The projection
method takes either an array of Projection
classes with the field name and a boolean flag indicating inclusion or exclusion, or Projection
syntactic sugar indicating which fields to include or exclude.
Example using the Projection
syntactic sugar:
package com.examples;
import com.datastax.astra.client.collections.Collection;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.collections.commands.options.CollectionFindOptions;
import com.datastax.astra.client.collections.commands.cursor.CollectionFindCursor;
import com.datastax.astra.client.core.query.Projection;
public class Find {
public static void main(String[] args) {
// Get an existing collection
Collection<Document> collection = new DataAPIClient("APPLICATION_TOKEN")
.getDatabase("API_ENDPOINT")
.getCollection("COLLECTION_NAME");
// Use a projection
Filter filter = Filters.eq("metadata.language", "English");
CollectionFindOptions options = new CollectionFindOptions()
.projection(Projection.include("is_checked_out", "title"));
CollectionFindCursor<Document, Document> cursor = collection.find(filter, options);
}
}
Example using an array of Projection
classes:
package com.examples;
import com.datastax.astra.client.collections.Collection;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.collections.commands.options.CollectionFindOptions;
import com.datastax.astra.client.collections.commands.cursor.CollectionFindCursor;
import com.datastax.astra.client.core.query.Projection;
public class Find {
public static void main(String[] args) {
// Get an existing collection
Collection<Document> collection = new DataAPIClient("APPLICATION_TOKEN")
.getDatabase("API_ENDPOINT")
.getCollection("COLLECTION_NAME");
// Use a projection
Filter filter = Filters.eq("metadata.language", "English");
CollectionFindOptions options =
new CollectionFindOptions()
.projection(
new Projection("is_checked_out", true),
new Projection("title", true));
CollectionFindCursor<Document, Document> cursor = collection.find(filter, options);
}
}
You can use any truthy value in the projection.
This example uses true
.
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME/COLLECTION_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"find": {
"filter": {"metadata.language": "English"},
"projection": {"is_checked_out": true, "title": true}
}
}'
Exclude specific fields
The following examples exclude the is_checked_out
and title
fields.
All fields prefixed with $
are excluded by default.
-
Python
-
TypeScript
-
Java
-
curl
Use a dictionary of field names to exclude.
from astrapy import DataAPIClient
# Get an existing collection
client = DataAPIClient()
database = client.get_database(
"API_ENDPOINT",
token="APPLICATION_TOKEN",
)
collection = database.get_collection("COLLECTION_NAME")
# Use a projection
cursor = collection.find(
{"metadata.language": "English"},
projection={"is_checked_out": False, "title": False}
)
The TypeScript client takes in an untyped Plain Old JavaScript Object (POJO) for the projection
parameter.
Consider type-casting to help you handle the return type.
You can use any falsy value in the projection.
This example uses false
.
import { DataAPIClient } from '@datastax/astra-db-ts';
// Get an existing collection
const client = new DataAPIClient('APPLICATION_TOKEN');
const database = client.db('API_ENDPOINT');
const collection = database.collection('COLLECTION_NAME');
// Use a projection
const cursor = collection.find(
{ "metadata.language": "English" },
{ projection: { is_checked_out: false, title: false} },
);
Java client has different Options
classes that provide a projection
method.
The projection
method takes either an array of Projection
classes with the field name and a boolean flag indicating inclusion or exclusion, or Projection
syntactic sugar indicating which fields to include or exclude.
Example using the Projection
syntactic sugar:
package com.examples;
import com.datastax.astra.client.collections.Collection;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.collections.commands.options.CollectionFindOptions;
import com.datastax.astra.client.collections.commands.cursor.CollectionFindCursor;
import com.datastax.astra.client.core.query.Projection;
public class Find {
public static void main(String[] args) {
// Get an existing collection
Collection<Document> collection = new DataAPIClient("APPLICATION_TOKEN")
.getDatabase("API_ENDPOINT")
.getCollection("COLLECTION_NAME");
// Use a projection
Filter filter = Filters.eq("metadata.language", "English");
CollectionFindOptions options = new CollectionFindOptions()
.projection(Projection.exclude("is_checked_out", "title"));
CollectionFindCursor<Document, Document> cursor = collection.find(filter, options);
}
}
Example using an array of Projection
classes:
package com.examples;
import com.datastax.astra.client.collections.Collection;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.collections.commands.options.CollectionFindOptions;
import com.datastax.astra.client.collections.commands.cursor.CollectionFindCursor;
import com.datastax.astra.client.core.query.Projection;
public class Find {
public static void main(String[] args) {
// Get an existing collection
Collection<Document> collection = new DataAPIClient("APPLICATION_TOKEN")
.getDatabase("API_ENDPOINT")
.getCollection("COLLECTION_NAME");
// Use a projection
Filter filter = Filters.eq("metadata.language", "English");
CollectionFindOptions options =
new CollectionFindOptions()
.projection(
new Projection("is_checked_out", false),
new Projection("title", false));
CollectionFindCursor<Document, Document> cursor = collection.find(filter, options);
}
}
You can use any falsy value in the projection.
This example uses false
.
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME/COLLECTION_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"find": {
"filter": {"metadata.language": "English"},
"projection": {"is_checked_out": false, "title": false}
}
}'
Explicitly include fields prefixed by $
All fields prefixed with $
are excluded by default.
You must explicitly include these fields in the projection if you want the Data API to return them.
Although you can’t specify a mix of included and excluded regular fields, you can specify a mix of included and excluded reserved fields (_id
or fields prefixed with $
).
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
# Get an existing collection
client = DataAPIClient()
database = client.get_database(
"API_ENDPOINT",
token="APPLICATION_TOKEN",
)
collection = database.get_collection("COLLECTION_NAME")
# Use a projection
cursor = collection.find(
{"metadata.language": "English"},
projection={"is_checked_out": False, "title": False, "$vector": True}
)
import { DataAPIClient } from '@datastax/astra-db-ts';
// Get an existing collection
const client = new DataAPIClient('APPLICATION_TOKEN');
const database = client.db('API_ENDPOINT');
const collection = database.collection('COLLECTION_NAME');
// Use a projection
const cursor = collection.find(
{ "metadata.language": "English" },
{ projection: { is_checked_out: false, title: false, $vector: true} },
);
package com.examples;
import com.datastax.astra.client.collections.Collection;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.collections.commands.options.CollectionFindOptions;
import com.datastax.astra.client.collections.commands.cursor.CollectionFindCursor;
import com.datastax.astra.client.core.query.Projection;
public class Find {
public static void main(String[] args) {
// Get an existing collection
Collection<Document> collection = new DataAPIClient("APPLICATION_TOKEN")
.getDatabase("API_ENDPOINT")
.getCollection("COLLECTION_NAME");
// Use a projection
Filter filter = Filters.eq("metadata.language", "English");
CollectionFindOptions options =
new CollectionFindOptions()
.projection(
new Projection("is_checked_out", false),
new Projection("title", false),
new Projection("$vector", true));
CollectionFindCursor<Document, Document> cursor = collection.find(filter, options);
}
}
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME/COLLECTION_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"find": {
"filter": {"metadata.language": "English"},
"projection": {"is_checked_out": false, "title": false, "$vector": true}
}
}'
Explicitly exclude the _id
field
_id
is included by default.
You must explicitly exclude _id
from the projection if you want the Data API to omit that field.
Although you can’t specify a mix of included and excluded regular fields, you can specify a mix of included and excluded special fields (_id
or fields prefixed with $
).
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
# Get an existing collection
client = DataAPIClient()
database = client.get_database(
"API_ENDPOINT",
token="APPLICATION_TOKEN",
)
collection = database.get_collection("COLLECTION_NAME")
# Use a projection
cursor = collection.find(
{"metadata.language": "English"},
projection={"is_checked_out": True, "title": True, "_id": False},
)
import { DataAPIClient } from '@datastax/astra-db-ts';
// Get an existing collection
const client = new DataAPIClient('APPLICATION_TOKEN');
const database = client.db('API_ENDPOINT');
const collection = database.collection('COLLECTION_NAME');
const cursor = collection.find(
{ "metadata.language": "English" },
{ projection: { is_checked_out: true, title: true, _id: false} },
);
package com.examples;
import com.datastax.astra.client.collections.Collection;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.collections.commands.options.CollectionFindOptions;
import com.datastax.astra.client.collections.commands.cursor.CollectionFindCursor;
import com.datastax.astra.client.core.query.Projection;
public class Find {
public static void main(String[] args) {
// Get an existing collection
Collection<Document> collection = new DataAPIClient("APPLICATION_TOKEN")
.getDatabase("API_ENDPOINT")
.getCollection("COLLECTION_NAME");
// Use a projection
Filter filter = Filters.eq("metadata.language", "English");
CollectionFindOptions options =
new CollectionFindOptions()
.projection(
new Projection("is_checked_out", true),
new Projection("title", true),
new Projection("_id", false));
CollectionFindCursor<Document, Document> cursor = collection.find(filter, options);
}
}
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME/COLLECTION_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"find": {
"filter": {"metadata.language": "English"},
"projection": {"is_checked_out": true, "title": true, "_id": false}
}
}'
Include all fields
The wildcard projection "*"
represents the whole document.
If you use this projection, it must be the only key in the projection.
If set to true, all fields are returned.
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
# Get an existing collection
client = DataAPIClient()
database = client.get_database(
"API_ENDPOINT",
token="APPLICATION_TOKEN",
)
collection = database.get_collection("COLLECTION_NAME")
# Use a projection
cursor = collection.find(
{"metadata.language": "English"},
projection={"*": True},
)
import { DataAPIClient } from '@datastax/astra-db-ts';
// Get an existing collection
const client = new DataAPIClient('APPLICATION_TOKEN');
const database = client.db('API_ENDPOINT');
const collection = database.collection('COLLECTION_NAME');
const cursor = collection.find(
{ "metadata.language": "English" },
{ projection: { "*": true } },
);
package com.examples;
import com.datastax.astra.client.collections.Collection;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.collections.commands.options.CollectionFindOptions;
import com.datastax.astra.client.collections.commands.cursor.CollectionFindCursor;
import com.datastax.astra.client.core.query.Projection;
public class Find {
public static void main(String[] args) {
// Get an existing collection
Collection<Document> collection = new DataAPIClient("APPLICATION_TOKEN")
.getDatabase("API_ENDPOINT")
.getCollection("COLLECTION_NAME");
// Use a projection
Filter filter = Filters.eq("metadata.language", "English");
CollectionFindOptions options =
new CollectionFindOptions()
.projection(new Projection("*", true));
CollectionFindCursor<Document, Document> cursor = collection.find(filter, options);
}
}
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME/COLLECTION_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"find": {
"filter": {"metadata.language": "English"},
"projection": {"*": true}
}
}'
Exclude all fields
The wildcard projection "*"
represents the whole of the document.
If you use this projection, it must be the only key in the projection.
If set to false, no fields are returned.
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
# Get an existing collection
client = DataAPIClient()
database = client.get_database(
"API_ENDPOINT",
token="APPLICATION_TOKEN",
)
collection = database.get_collection("COLLECTION_NAME")
# Use a projection
cursor = collection.find(
{"metadata.language": "English"},
projection={"*": False},
)
import { DataAPIClient } from '@datastax/astra-db-ts';
// Get an existing collection
const client = new DataAPIClient('APPLICATION_TOKEN');
const database = client.db('API_ENDPOINT');
const collection = database.collection('COLLECTION_NAME');
const cursor = collection.find(
{ "metadata.language": "English" },
{ projection: { "*": false } },
);
package com.examples;
import com.datastax.astra.client.collections.Collection;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.collections.commands.options.CollectionFindOptions;
import com.datastax.astra.client.collections.commands.cursor.CollectionFindCursor;
import com.datastax.astra.client.core.query.Projection;
public class Find {
public static void main(String[] args) {
// Get an existing collection
Collection<Document> collection = new DataAPIClient("APPLICATION_TOKEN")
.getDatabase("API_ENDPOINT")
.getCollection("COLLECTION_NAME");
// Use a projection
Filter filter = Filters.eq("metadata.language", "English");
CollectionFindOptions options =
new CollectionFindOptions()
.projection(new Projection("*", false));
CollectionFindCursor<Document, Document> cursor = collection.find(filter, options);
}
}
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME/COLLECTION_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"find": {
"filter": {"metadata.language": "English"},
"projection": {"*": false}
}
}'
Include or exclude array elements
For array fields, you can use $slice
to specify which elements of the array to return.
-
Python
-
TypeScript
-
Java
-
curl
Instead of using True
or False
, use {"$slice": SLICE_VALUE}
to indicate which array indexes to include.
For example:
-
Return the first two indexes:
{"field_name": {"$slice": 2}}
-
Return the last two indexes:
{"field_name": {"$slice": -2}}
-
Return two indexes, starting at index 4:
{"field_name": {"$slice": [4, 2]}}
-
Return two indexes, starting at the fourth index from the end:
{"field_name": {"$slice": [-4, 2]}}
from astrapy import DataAPIClient
# Get an existing collection
client = DataAPIClient()
database = client.get_database(
"API_ENDPOINT",
token="APPLICATION_TOKEN",
)
collection = database.get_collection("COLLECTION_NAME")
# Use a projection
cursor = collection.find(
{"metadata.language": "English"},
projection={"genres": {"$slice": [4, 2]}, "title": True},
)
Instead of using true
or false
, use {$slice: SLICE_VALUE}
to indicate which array indexes to include.
For example:
-
Return the first two indexes:
{ field_name: { $slice: 2 } }
-
Return the last two indexes:
{ field_name: { $slice: -2 } }
-
Return two indexes, starting at index 4:
{ field_name: { $slice: [4, 2] } }
-
Return two indexes, starting at the fourth index from the end:
{ field_name: { $slice: [-4, 2] } }
import { DataAPIClient } from '@datastax/astra-db-ts';
// Get an existing collection
const client = new DataAPIClient('APPLICATION_TOKEN');
const database = client.db('API_ENDPOINT');
const collection = database.collection('COLLECTION_NAME');
const cursor = collection.find(
{ "metadata.language": "English" },
{ projection: { genres: { $slice: [4, 2] }, title: true} },
);
Set the present
parameter of the Projection
class to null
, and specify the sliceStart
and sliceEnd
parameters.
For example:
-
Return the first two indexes:
sliceStart
is2
,sliceEnd
isnull
-
Return the last two indexes:
sliceStart
is-2
,sliceEnd
isnull
-
Return two indexes, starting at index 4:
sliceStart
is4
,sliceEnd
is2
-
Return two indexes, starting at the fourth index from the end:
sliceStart
is-4
,sliceEnd
is2
package com.examples;
import com.datastax.astra.client.collections.Collection;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.collections.commands.options.CollectionFindOptions;
import com.datastax.astra.client.collections.commands.cursor.CollectionFindCursor;
import com.datastax.astra.client.core.query.Projection;
public class Find {
public static void main(String[] args) {
// Get an existing collection
Collection<Document> collection = new DataAPIClient("APPLICATION_TOKEN")
.getDatabase("API_ENDPOINT")
.getCollection("COLLECTION_NAME");
// Use a projection
Filter filter = Filters.eq("metadata.language", "English");
CollectionFindOptions options =
new CollectionFindOptions()
.projection(
new Projection("genres", null, 4, 2),
new Projection("title", true));
CollectionFindCursor<Document, Document> cursor = collection.find(filter, options);
}
}
Instead of using true
or false
, use {"$slice": SLICE_VALUE}
to indicate which array indexes to include.
For example:
-
Return the first two indexes:
{"field_name": {"$slice": 2}}
-
Return the last two indexes:
{"field_name": {"$slice": -2}}
-
Return two indexes, starting at index 4:
{"field_name": {"$slice": [4, 2]}}
-
Return two indexes, starting at the fourth index from the end:
{"field_name": {"$slice": [-4, 2]}}
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME/COLLECTION_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"find": {
"filter": {"metadata.language": "English"},
"projection": {"genres": { "$slice": [4, 2] }, "title": true}
}
}'
Include or exclude nested fields
To refer to nested fields in the projection, use dot notation.
For example, field.subfield.subsubfield
.
You can’t reference overlapping paths.
For example, using both continent.country
and continent.country.city
in a projection will raise an error.
If you exclude all subfields of a field, then the return value of the field will be an empty object.
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
# Get an existing collection
client = DataAPIClient()
database = client.get_database(
"API_ENDPOINT",
token="APPLICATION_TOKEN",
)
collection = database.get_collection("COLLECTION_NAME")
# Use a projection
cursor = collection.find(
{"metadata.language": "English"},
projection={"metadata.edition": True, "title": True},
)
import { DataAPIClient } from '@datastax/astra-db-ts';
// Get an existing collection
const client = new DataAPIClient('APPLICATION_TOKEN');
const database = client.db('API_ENDPOINT');
const collection = database.collection('COLLECTION_NAME');
// Use a projection
const cursor = collection.find(
{ "metadata.language": "English" },
{ projection: { "metadata.edition": true, title: true} },
);
Example using the Projection
syntactic sugar:
package com.examples;
import com.datastax.astra.client.collections.Collection;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.collections.commands.options.CollectionFindOptions;
import com.datastax.astra.client.collections.commands.cursor.CollectionFindCursor;
import com.datastax.astra.client.core.query.Projection;
public class Find {
public static void main(String[] args) {
// Get an existing collection
Collection<Document> collection = new DataAPIClient("APPLICATION_TOKEN")
.getDatabase("API_ENDPOINT")
.getCollection("COLLECTION_NAME");
// Use a projection
Filter filter = Filters.eq("metadata.language", "English");
CollectionFindOptions options = new CollectionFindOptions()
.projection(Projection.include("metadata.edition", "title"));
CollectionFindCursor<Document, Document> cursor = collection.find(filter, options);
}
}
Example using an array of Projection
classes:
package com.examples;
import com.datastax.astra.client.collections.Collection;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.collections.commands.options.CollectionFindOptions;
import com.datastax.astra.client.collections.commands.cursor.CollectionFindCursor;
import com.datastax.astra.client.core.query.Projection;
public class Find {
public static void main(String[] args) {
// Get an existing collection
Collection<Document> collection = new DataAPIClient("APPLICATION_TOKEN")
.getDatabase("API_ENDPOINT")
.getCollection("COLLECTION_NAME");
// Use a projection
Filter filter = Filters.eq("metadata.language", "English");
CollectionFindOptions options =
new CollectionFindOptions()
.projection(
new Projection("metadata.edition", true),
new Projection("title", true));
CollectionFindCursor<Document, Document> cursor = collection.find(filter, options);
}
}
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME/COLLECTION_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"find": {
"filter": {"metadata.language": "English"},
"projection": {"metadata.edition": true, "title": true}
}
}'