Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query rules retriever #114855

Merged
merged 42 commits into from
Oct 28, 2024
Merged

Conversation

kderusso
Copy link
Member

@kderusso kderusso commented Oct 15, 2024

Example script to demonstrate:

PUT my-index/_doc/id1
{
  "text": "ID1 - pinned doc for foo"
}

PUT my-index/_doc/id2
{
  "text": "ID2 - exclude doc for bar"
}

PUT my-index/_doc/id3
{
  "text": "ID3 - baz, no rule attached"
}

PUT /_query_rules/my-ruleset
{
  "rules": [
    {
      "rule_id": "rule1",
      "type": "pinned",
      "criteria": [
        {
          "type": "exact",
          "metadata": "foo",
          "values": [ "foo" ]
        }
      ],
      "actions": {
        "ids": [
          "id1"
        ]
      }
    },
    {
      "rule_id": "rule2",
      "type": "exclude",
      "criteria": [
        {
          "type": "exact",
          "metadata": "bar",
          "values": [ "bar" ]
        }
      ],
      "actions": {
        "ids": [
          "id2"
        ]
      }
    }
  ]
}

GET my-index/_search
{
  "retriever": {
    "rule": {
      "match_criteria": {
        "foo": "foo",
        "bar": "bar"
      },
      "ruleset_ids": [
        "my-ruleset"
      ],
      "retriever": {
        "standard": {
          "query": {
            "query_string": {
              "query": "bar"
            }
          }
        }
      }
    }
  },
  "explain": true
}

GET my-index/_search
{
  "retriever": {
    "rule": {
      "match_criteria": {
        "foo": "foo",
        "bar": "bar"
      },
      "ruleset_ids": [
        "my-ruleset"
      ],
      "retriever": {
        "rrf": {
          "retrievers": [
            {
              "standard": {
                "query": {
                  "query_string": {
                    "query": "bar"
                  }
                }
              }
            },
            {
              "standard": {
                "query": {
                  "query_string": {
                    "query": "baz"
                  }
                }
              }
            }
          ]
        }
      }
    }
  }
}

kderusso and others added 12 commits October 15, 2024 13:48
* Add data stream template validation

to snapshot restore

* Add data stream template validation

to data stream promotion endpoint

* Add new assertion for response headers

Add a new assertion to synchronously execute a request and check the
response contains a specific warning header

* Test for warning header on snapshot restore

When missing templates

* Test for promotion warnings

* Add documentation for the potential error states

* PR changes

* Spotless reformatting

* Add logic to look in snapshot global metadata

This checks if the snapshot contains a matching template for the DS

* Comment on test cleanup to explain it was copied

* Removed cluster service field
@kderusso
Copy link
Member Author

@elasticmachine merge upstream

@kderusso
Copy link
Member Author

@elasticmachine update branch

@kderusso kderusso changed the title WIP: Query rules retriever Query rules retriever Oct 21, 2024
@kderusso kderusso requested review from jimczi and a team October 21, 2024 17:39
@kderusso kderusso requested a review from pmpailis October 22, 2024 19:56
Copy link
Contributor

@pmpailis pmpailis left a comment

Choose a reason for hiding this comment

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

Thanks @kderusso ! Some minor comments only, but this looks good!

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

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

Thanks @kderusso
I left more comments.
We also need a test that extends AbstractXContentTestCase<QueryRuleRetrieverBuilder> to validate the rest parsing.

Copy link
Contributor

@pmpailis pmpailis left a comment

Choose a reason for hiding this comment

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

LGTM! :shipit:

@kderusso kderusso requested a review from jimczi October 24, 2024 19:07
Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

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

LGTM

@kderusso kderusso enabled auto-merge (squash) October 28, 2024 20:27
@kderusso kderusso merged commit 690ad1e into elastic:main Oct 28, 2024
16 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.x Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 114855

kderusso added a commit to kderusso/elasticsearch that referenced this pull request Oct 29, 2024
kderusso added a commit that referenced this pull request Oct 29, 2024
ioanatia pushed a commit to ioanatia/elasticsearch that referenced this pull request Nov 4, 2024
jfreden pushed a commit to jfreden/elasticsearch that referenced this pull request Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged backport pending >enhancement :SearchOrg/Relevance Label for the Search (solution/org) Relevance team v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants