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

GraphQL field filtering is using the wrong field index #17323

Closed
gvkries opened this issue Jan 9, 2025 · 2 comments · Fixed by #17378
Closed

GraphQL field filtering is using the wrong field index #17323

gvkries opened this issue Jan 9, 2025 · 2 comments · Fixed by #17378

Comments

@gvkries
Copy link
Contributor

gvkries commented Jan 9, 2025

Describe the bug

When filtering content items in GraphQL by indexed content fields, the field name and part are not considered. This issue arises when multiple fields of the same type are added to a content type, leading to incorrect items being returned. Specifically, querying one field may inadvertently include values from another field of the same type.

Orchard Core version

2.x and newer

To Reproduce

  1. Enable indexing for content fields.
  2. Create a content type with two fields of the same kind (e.g., two numeric fields).
  3. Create content items with different values in each field.
  4. Perform a GraphQL query for one of the fields.
  5. Observe that the query results incorrectly include values from the other field.

Expected Behavior

The GraphQL query should only return items that match the specified field and part, without including values from other fields of the same type.

Logs and screenshots

image

@Piedone Piedone added the GraphQL label Jan 9, 2025
@sebastienros sebastienros added this to the 3.x milestone Jan 9, 2025
Copy link
Contributor

github-actions bot commented Jan 9, 2025

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

@gvkries
Copy link
Contributor Author

gvkries commented Jan 16, 2025

Related SQL query:

SELECT [Document].* FROM [Document] 
  INNER JOIN (
    SELECT [Document].[Id], ContentItemIndex_a1.[CreatedUtc] AS order_1 FROM [Document] 
      INNER JOIN [ContentItemIndex] AS ContentItemIndex_a1 ON ContentItemIndex_a1.[DocumentId] = [Document].[Id] 
      INNER JOIN [NumericFieldIndex] AS NumericFieldIndex_a1 ON NumericFieldIndex_a1.[DocumentId] = [Document].[Id] 
        WHERE [Document].[Type] = @Type AND  ((ContentItemIndex_a1.[Published] = @p1) AND (ContentItemIndex_a1.[ContentType] = @p2) AND (([Numeric] = @x1))) 
        GROUP BY [Document].[Id] 
        ORDER BY order_1 DESC LIMIT 100
  ) AS IndexQuery ON IndexQuery.[Id] = [Document].[Id] 
  ORDER BY order_1 DESC

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

Successfully merging a pull request may close this issue.

3 participants