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

Conjunction always using AND inside Condition Groups #54

Open
only4kaustav opened this issue Sep 21, 2022 · 1 comment
Open

Conjunction always using AND inside Condition Groups #54

only4kaustav opened this issue Sep 21, 2022 · 1 comment

Comments

@only4kaustav
Copy link

only4kaustav commented Sep 21, 2022

Hello,

Looks like conjunction inside just below Condition Groups is always taking AND, irrespective of conjunction supplied.

Main Query

query ($key: [String]!, $offset: Int!, $limit: Int!, $filters: ConditionGroupInput, $sort: [SortInput]) {
      searchAPISearch(index_id: "myindex", condition_group: $filters, range: {offset: $offset, limit: $limit}, fulltext: {keys: $key}, sort: $sort) {
        count: result_count
        documents {
          ... on MyindexDoc  {
            group__title
            content__content_title
          }
        }
      }
    }

Scenario 1 : Supplied query variables (giving expected result)

{
  "offset": "0",
  "limit": 50,
  "key": "test",
  "filters": {
    "conjunction": "OR",
    "groups": [
      { 
        "conditions": [
          {
            "operator": "=",
            "name": "content__content_type",
            "value": "article"
          },
          {
            "operator": "=",
            "name": "content__field_is_application",
            "value": "yes"
          },
          {
            "operator": "<>",
            "name": "content__field_life_cycle__entity__name",
            "value": "Retired"
          }
        ]
      }
    ]
  },
  "sort": [
    {
      "field": "search_api_relevance",
      "value": "desc"
    }
  ]
}

Scenario 2 : Supplied query variables (giving expected result)

{
  "offset": "0",
  "limit": 50,
  "key": "test",
  "filters": {
    "conjunction": "OR",
    "groups": [
      {
        "conditions": [
          {
            "operator": ">",
            "name": "group__id",
            "value": "0"
          },
          {
            "operator": "<>",
            "name": "group__field_life_cycle__entity__title",
            "value": "Retired"
          },
          {
            "operator": "<>",
            "name": "group__field_is_live",
            "value": "0"
          }
        ]
      }
    ]
  },
  "sort": [
    {
      "field": "search_api_relevance",
      "value": "desc"
    }
  ]
}

Scenario 3 : Supplied query variables (giving 0 result, but it should be result of Scenario 1 + Scenario 2)

{
  "offset": "0",
  "limit": 50,
  "key": "test",
  "filters": {
    "conjunction": "OR",
    "groups": [
      { 
        "conditions": [
          {
            "operator": "=",
            "name": "content__content_type",
            "value": "article"
          },
          {
            "operator": "=",
            "name": "content__field_is_application",
            "value": "yes"
          },
          {
            "operator": "<>",
            "name": "content__field_life_cycle__entity__name",
            "value": "Retired"
          }
        ]
      },
      {
        "conditions": [
          {
            "operator": ">",
            "name": "group__id",
            "value": "0"
          },
          {
            "operator": "<>",
            "name": "group__field_life_cycle__entity__title",
            "value": "Retired"
          },
          {
            "operator": "<>",
            "name": "group__field_is_live",
            "value": "0"
          }
        ]
      }
    ]
  },
  "sort": [
    {
      "field": "search_api_relevance",
      "value": "desc"
    }
  ]
}

What I assume conjunction just above groups always using AND operation between groups objects, but I want to use OR here.
Am I doing something wrong?

@only4kaustav
Copy link
Author

Any feedback/comment against this?

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

No branches or pull requests

1 participant