Skip to content

Add documentation for element filter#4558

Open
johansolbakken wants to merge 2 commits intomasterfrom
johsol/element-filter-documentation
Open

Add documentation for element filter#4558
johansolbakken wants to merge 2 commits intomasterfrom
johsol/element-filter-documentation

Conversation

@johansolbakken
Copy link
Contributor

@johansolbakken johansolbakken commented Mar 3, 2026

I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@havardpe please review
@boeker please review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds documentation for the elementFilter annotation / element-index filtering across the YQL and JSON query language reference docs, plus an additional CLI query example.

Changes:

  • Document elementFilter usage with sameElement() in the YQL reference, including the single-index shorthand syntax.
  • Add JSON Query Language documentation for the equals operator, including an index parameter for matching a specific multivalue element.
  • Add a Query Language page example that links to the elementFilter documentation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
en/reference/querying/yql.html Adds elementFilter narrative + adds elementFilter to the annotations table.
en/reference/querying/json-query-language.md Adds an equals section and documents the index parameter for element-index matching.
en/querying/query-language.html Adds a CLI example for matching a specific multivalue element, linking to elementFilter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@boeker boeker left a comment

Choose a reason for hiding this comment

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

See the comments. 🙏

struct-field value { indexing: attribute }
}
</pre>
<p id="element-index">Element index: Match a specific element in a multivalue field:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the syntax be used for any multivalue field or just arrays?

More generally, do we want this example here? Since there are only three examples here, I am not sure if this is important enough to be added here.

}
```

Short form using an array — `[field, value]` is shorthand for `{ "field": field, "value": value }`:
Copy link
Contributor

Choose a reason for hiding this comment

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

This sentence is hard to read. The " Short form using an array — [field, value]" was hard to parse in my head.

Once could say something like "This can also be expressed using the following shorthand form:"

Edit: I suggested "shorthand form" while you later use "shorthand syntax". Imo "shorthand form" sounds better, but it does not matter what we use as long as we are consistent.


The `equals` operator supports boolean and integer values.

To match at a specific element index in a multivalue field, add the `index` parameter.
Copy link
Contributor

Choose a reason for hiding this comment

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

(Unsure about multivalue fields as above)

<pre>
where my_numbers contains ({elementFilter:[2]}sameElement("42"))
</pre>
<p>This only matches in the element at index 2.
Copy link
Contributor

Choose a reason for hiding this comment

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

"matches in the element at index 2" sounds wrong. (Matching in an element, can you say that?)

"matches in the field at index 2" or "matches the element at index 2" makes more sense imo.

<p>This only matches in the element at index 2.
Multiple indices can be given: <code>{elementFilter:[0, 2, 5]}</code>.</p>

<p>A shorthand syntax is also available for matching a single element index:</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

"for matching at a single element index" maybe? Since we are not matching the index itself but the element at that index.

Edit: Or just use "A shorthand syntax is also available:" since you already have the remark below.

Comment on lines +420 to +421
<p>The shorthand only supports a single index.
Use the annotation form with <code>elementFilter</code> to match multiple indices.</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

This repeats what was said before.

Only the elements at the given indices are required to match.
</p>
<pre>
where my_numbers contains ({elementFilter:[2]}sameElement("42"))
Copy link
Contributor

Choose a reason for hiding this comment

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

I would use multiple indices here.

<td>
<p id="elementfilter">
Used with <a href="#sameelement">sameElement</a>.
Restricts matching to specific element indices in a multivalue field.
Copy link
Contributor

Choose a reason for hiding this comment

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

(Multivalue field again.)

<p id="elementfilter">
Used with <a href="#sameelement">sameElement</a>.
Restricts matching to specific element indices in a multivalue field.
Only the elements at the given indices are required to match.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this sentence mean? I would be very explicit: "Makes sameElement match if and only if there is a match at one or more of the specified indicies."

@johansolbakken
Copy link
Contributor Author

Thanks! I will take a look👍🏻

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.

3 participants