Skip to content

[CPS] Add CPS examples#5412

Open
szabosteve wants to merge 3 commits intomainfrom
szabosteve/cps-examples
Open

[CPS] Add CPS examples#5412
szabosteve wants to merge 3 commits intomainfrom
szabosteve/cps-examples

Conversation

@szabosteve
Copy link
Contributor

@szabosteve szabosteve commented Mar 9, 2026

Summary

Relates to https://github.com/elastic/docs-content-internal/issues/31

This PR adds CPS examples to the CPS overview page.

Generative AI disclosure

  1. Did you use a generative AI (GenAI) tool to assist in creating this contribution?
  • Yes
  • No
  1. If you answered "Yes" to the previous question, please specify the tool(s) and model(s) used (e.g., Google Gemini, OpenAI ChatGPT-4, etc.).

Tool(s) and model(s) used: gpt 5.2 in Codex

@szabosteve szabosteve added documentation Improvements or additions to documentation Team:Developer Issues owned by the Developer Docs Team CPS labels Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Vale Linting Results

Summary: 1 warning found

⚠️ Warnings (1)
File Line Rule Message
explore-analyze/cross-project-search.md 361 Elastic.QuotesPunctuation Place punctuation inside closing quotation marks.

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.

@szabosteve szabosteve requested a review from quux00 March 9, 2026 16:00
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

🔍 Preview links for changed docs

@szabosteve szabosteve marked this pull request as ready for review March 9, 2026 17:05
@szabosteve szabosteve requested review from a team as code owners March 9, 2026 17:05
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.

Found a few things to fix.

* more complex project_routing examples
* qualified search expressions and project_routing
-->
The following examples demonstrate how search requests behave in different cross-project scenarios in {{cps-init}}.
Copy link

Choose a reason for hiding this comment

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

nit: I think this will read as:

in different cross-project scenarios in Cross-project search

which seems a little redudant?

Maybe:

in different {{cps-init}} scenarios

POST /_query
{
"query": "FROM my-index",
"include_ccs_metadata": true
Copy link

Choose a reason for hiding this comment

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

Change include_ccs_metadata to include_execution_metadata. Sorry, I used the wrong one in my examples to you.

include_ccs_metadata is (unofficially) deprecated - we don't want to use it for two reasons:

  1. it has "ccs" in it so confusing if it applies to cps
  2. include_execution_metadata will include execution metadata even for queries that are origin-only, whereas include_ccs_metadata will not

GET /_query
{
"query": "SET project_routing=\"_alias:lin*\"; FROM * METADATA _index",
"include_ccs_metadata":true
Copy link

Choose a reason for hiding this comment

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

Change include_ccs_metadata to include_execution_metadata.

{
"project_routing": "@origin-only",
"query": "FROM *",
"include_ccs_metadata": true,
Copy link

Choose a reason for hiding this comment

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

Change include_ccs_metadata to include_execution_metadata.


The requests explicitly target all projects using the `*:` prefix.
The `my-index` index is evaluated separately in each project.
The search runs only in projects where the `my-index` index exists.
Copy link

Choose a reason for hiding this comment

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

The search runs only in projects where the my-index index exists.

That's not true for qualified expressions. When you specify *:my-index, that index (or alias or datastream) must be present on every project, otherwise an error will be thrown:

Here's a case where the "logs" index exists on the linked project but not on the origin project:

$ ▶ curl -X POST --url 'http://localhost:9200/*:logs/_search' --header 'Authorization: ApiKey essu_dev_xxxx' | jq .
{
  "error": {
    "root_cause": [
      {
        "type": "index_not_found_exception",
        "reason": "no such index [*:logs]",
        "index_uuid": "_na_",
        "index": "*:logs"
      }
    ],
    "type": "index_not_found_exception",
    "reason": "no such index [*:logs]",
    "index_uuid": "_na_",
    "index": "*:logs"
  },
  "status": 404
}

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

Labels

CPS documentation Improvements or additions to documentation Team:Developer Issues owned by the Developer Docs Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants