How to filter out by multiple fields in SEARCH API?

Hi gyus,

we need to get search results filtered by 2 fields. All results should have both values that is why we need an and condition.

We use this one:

Filters: 'type::metadata && tags::E69D3813-F485-4971-B917-407B1037058A '

But it does not work. We receive all results as for filters: 'type::metadata'.

Have you any idea, what do we do wrong? What will be the properly use of an and operator in search api?

Thank you in advance!

Best regards,

Ecaterina

Parents
  • Hi Ecaterina,

    I haven't used the search API in a bit, but I believe that your filter would look like this.

    "type::metadata||tags::E69D3813-F485-4971-B917-407B1037058A"

    The "||" is just a delimiter and doesn't imply any type of boolean logic.  Filters always use AND boolean logic, unless you specify multiple values for a field.

    For example, "type::metadata||tags::tag1,tag2,tag3".  In this case the "," is used to delimit the values for tags, which implies OR logic.  In other words type == "metadata" AND tags contains "tag1" OR "tag2" OR "tag3".

    If you needed to use some other boolean logic, like an OR, you can do that through the Query param which supports more complex Solr queries.

Reply
  • Hi Ecaterina,

    I haven't used the search API in a bit, but I believe that your filter would look like this.

    "type::metadata||tags::E69D3813-F485-4971-B917-407B1037058A"

    The "||" is just a delimiter and doesn't imply any type of boolean logic.  Filters always use AND boolean logic, unless you specify multiple values for a field.

    For example, "type::metadata||tags::tag1,tag2,tag3".  In this case the "," is used to delimit the values for tags, which implies OR logic.  In other words type == "metadata" AND tags contains "tag1" OR "tag2" OR "tag3".

    If you needed to use some other boolean logic, like an OR, you can do that through the Query param which supports more complex Solr queries.

Children