Magento – Using searchCriteria while searching attributes in magento 2.0

apimagento-enterprisemagento2restsearch-criteria

Fetching attribute info, if I apply multiple filters in a single search criteria, it does not work. But in case of single filter it works perfectly.

Multiple filters HTTP request:

http://192.168.1.180/magento/index.php/rest/V1/products/attributes?searchCriteria[filter_groups][0][filters][0][field]=attribute_code&searchCriteria[filter_groups][0][filters][0][value]=color&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&searchCriteria[filter_groups][0][filters][1][field]=attribute_code&searchCriteria[filter_groups][0][filters][1][value]=size&searchCriteria[filter_groups][0][filters][1][condition_type]=eq

Output: 
{
  "items": [],
  "search_criteria": {
    "filter_groups": [
      {
        "filters": [
          {
            "field": "attribute_code",
            "value": "size",
            "condition_type": "eq"
          },
          {
            "field": "attribute_code",
            "value": "color",
            "condition_type": "eq"
          }
        ]
      }
    ]
  },
  "total_count": 0
}

But when I hit the single filter one, I get results for both size as well as color.

Single filter:

http://192.168.1.180/magento/index.php/rest/V1/products/attributes?searchCriteria[filter_groups][0][filters][0][field]=attribute_code&searchCriteria[filter_groups][0][filters][0][value]=color&searchCriteria[filter_groups][0][filters][0][condition_type]=eq

UPDATE: Tried the in filter but still no results

{
  "items": [],
  "search_criteria": {
    "filter_groups": [
      {
        "filters": [
          {
            "field": "attribute_code",
            "value": "color,size",
            "condition_type": "in"
          }
        ]
      }
    ]
  },
  "total_count": 0
}

UPDATE 2: Tried "in" in different filters

{
  "items": [],
  "search_criteria": {
    "filter_groups": [
      {
        "filters": [
          {
            "field": "attribute_code",
            "value": "color",
            "condition_type": "in"
          },
          {
            "field": "attribute_code",
            "value": "size",
            "condition_type": "in"
          }
        ]
      }
    ]
  },
  "total_count": 0
}

UPDATE 3: Tried "in" filter in separate filter groups

{
  "items": [],
  "search_criteria": {
    "filter_groups": [
      {
        "filters": [
          {
            "field": "attribute_code",
            "value": "color",
            "condition_type": "in"
          }
        ]
      },
      {
        "filters": [
          {
            "field": "attribute_code",
            "value": "size",
            "condition_type": "in"
          }
        ]
      }
    ]
  },
  "total_count": 0
}

Best Answer

Here is the fix for the "in" problem, this will probably be fixed in next release: https://github.com/magento/magento2/commit/65819d2f61a63e4fa9fc978220f8662ee5472791