Skip to content

Add ESQL CPS doc#5402

Draft
leemthompo wants to merge 6 commits intomainfrom
leemthompo/cpsql
Draft

Add ESQL CPS doc#5402
leemthompo wants to merge 6 commits intomainfrom
leemthompo/cpsql

Conversation

@leemthompo
Copy link
Contributor

@leemthompo leemthompo commented Mar 9, 2026

Issue: #4167

Duplication

If ESQL deserves its own page for CPS, then a minimum of reiteration is required.

That said, I'm sure there's some duplication versus the core CPS docs here that might be overkill, reviewer please flag what you think doesn't need to be reiterated here.

Important

Eventually this doc will live in elasticsearch alongside the bulk of the rest of the ESQL docs, so this PR will get closed and recreated

Generative AI disclosure

  1. Did you use a generative AI (GenAI) tool to assist in creating this contribution?
  • Yes
  • No

Tool(s) and model(s) used: Claude Code, Opus 4.6

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

✅ Vale Linting Results

No issues found on modified lines!


The Vale linter checks documentation changes against the Elastic Docs style guide.

To use Vale locally or report issues, refer to Elastic style guide for Vale.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

The default behavior is to query across the origin project and all linked projects automatically.
The following example queries the `data` index and includes the `_index` metadata field to identify which project each result came from:

```esql
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: technically this is a rest request, not sure if we mark them differently

1. `data` is resolved across all projects. `_origin:logs` is resolved only in the origin project.

::::{tip}
Error handling differs between expression types. Unqualified expressions fail only if the index exists in none of the searched projects. Qualified expressions fail if the index is missing from the targeted project, regardless of whether it exists elsewhere.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in none of the searched projects -> in none of the linked projects
searched sounds ambiguous to me. Should we rename it to linked?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But "linked" is not right. It also includes origin. So the change suggested by Ievgen would be less correct than what is already there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left as-is for moment

Copy link
Contributor

@szabosteve szabosteve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some tiny comments; please take or leave them. LGTM!


:::{note}
Project routing expressions use Lucene query syntax. The `:` operator matches a tag value, equivalent to `=` in other query languages. For example, `_alias:my-project` matches projects whose alias is `my-project`.
:::
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. Thanks for adding this!

- Use {{cps-init}} instead of CPS in "Before you begin"
- Use "scope" terminology instead of "filtering" for project-level selection
- "project identifier" → "project alias" in search expressions intro
- Mark REST API request blocks as console instead of esql/json
- Add include_execution_metadata: true to default query example
- Link SET command docs; clarify SET-first rule and multi-param ordering
- Project routing: "excluded projects are never queried"
- Add WHERE caveat with link to dedicated section in metadata bullet
- WHERE tip: "To optimize a query" instead of "To prevent unnecessary queries"
- Replace single-project routing+METADATA example with multi-project _alias:*linked* example
- Limitations: remove "in esql" qualifier; "Initially" instead of "Currently"
@leemthompo
Copy link
Contributor Author

@idegtiarenko @szabosteve @quux00 thanks all for the thorough review! 6709404 should address all the feedback

lmk if anything looks off

Copy link
Contributor

@naj-h naj-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leemthompo the doc is pretty clear. But like you pointed out in the issue, there are repetitions with other docs like https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/5402/explore-analyze/cross-project-search/cross-project-search-project-routing#creating-and-managing-named-project-routing-expressions
If we really want to have an ESQL-specific page, then I think we should probably not repeat the content listed in the other pages that are listed the main CPS page as those are language agnostic (like project routing and tags)


Both options support referencing a named project routing expression using the `@` prefix.
Before you can reference a named expression, you must create it using the `_project_routing` API.
For instructions, refer to [Using named project routing expressions](/explore-analyze/cross-project-search/cross-project-search-project-routing.md#named-routing-expressions).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1. `data` is resolved across all projects except the origin project.

::::{note}
`*:` in {{cps-init}} does not behave like `*:` in cross-cluster search (CCS):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a Serverless customer might not know what CCS is, so probably worth linking to a doc or at least specify that it is a feature available in stateful deployments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


- **[Query all projects](#query-all-projects-default)**: If you just want to query across all linked projects, no special syntax is required. Queries automatically run against the origin and all linked projects by default.
- **[Use project routing](#use-project-routing)**: Use project routing to limit the scope of your search to specific projects before query execution. Excluded projects are not queried.
- **[Use search expressions](#use-search-expressions)**: Use search expressions for fine-grained control over which projects and indices are queried, by qualifying index names with a project alias. Search expressions can be used independently or combined with project routing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quux00 @szabosteve @leemthompo probably a nit - but I realize that we've been calling this Search expressions (qualified/unqualified search expressions) in this doc and the previous ones. It sounds a bit off to me, as internally we've been calling this "qualified/unqualified index expressions", which makes more sense to me as these are the index expressions parts of the request. Search expression sounds more broad. Any thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good I think we can tighten up the core definition of qualified/unqualified expressions too to be clearer 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated in 8e9d245

@leemthompo
Copy link
Contributor Author

But like you pointed out in the issue, there are repetitions with other docs like https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/5402/explore-analyze/cross-project-search/cross-project-search-project-routing#creating-and-managing-named-project-routing-expressions
If we really want to have an ESQL-specific page, then I think we should probably not repeat the content listed in the other pages that are listed the main CPS page as those are language agnostic (like project routing and tags)

definitely true @naj-h just felt like there was enough ESQL-specific info to warrant its own page, and I tried to keep repetition to a minimum, but was a necessary evil to introduce some of the sections

I'll be closing and recreating this PR in Elasticsearch repo to live alongside the rest of the ESQL docs —I'll make sure you have time to look at that again, and we can trim stuff there if we feel it's important

| STATS COUNT(*)
```

1. Routes the query to projects whose alias is `my-project`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "projects" should probably not be plural here since there is no wildcard in the alias project routing. So either:

(1) change the project_routing to be _alias:my-project* and in the note say " Routes the query to projects whose alias starts with my-project.

(2) change the note to say: " Routes the query to the project with alias is my-project"

Copy link

@quux00 quux00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One minor nit suggestion left.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants