Advanced feature
Or Groups are an advanced feature. We recommend getting some experience with ILSA before trying this.
When searching with ILSA, usually your filters are AND-filters: The visitor wants vehicles that have both warranty and air condition. Not vehicles that have just one of those. You can do simple OR-queries if you accept either value in a field (for example make Audi or BMW). But if you want to do OR-queries that span multiple fields, you’ll need Or Groups. For example searching for Audi A3 or BMW 1-series.
While you might expect this to be simple, it sadly is not. Consider for example that you also need the values for the dropdowns.
To get started, go to the backoffice and change your general.make.normalized
and general.model.normalized
searchable fields to be in the same Or Group. Let’s call your new OrGroup “makemodel”. The API your website calls will now need to be called differently:
?general.make.normalized=bmw
becomes?makemodel[0].general.make.normalized=bmw
?general.model.normalized=bmw/1-series
becomes?makemodel[0]=general.model.normalized=bmw/1-series
?_fields=general.make.normalized
becomes?_fields=makemodel[0].general.make.normalized
?_fields=general.model.normalized
becomes?_fields=makemodel[0].general.model.normalized
and you can now also add a second Or Group Clause for another make/model. For example by adding &makemodel[1].general.make.normalized=audi&makemodel[1].general.model.normalized=audi/a3&_fields=makemodel[1].general.make.normalized&_fields=makemodel[1].general.model.normalized
.
The response will also change. Instead of a top-level fields['general.make.normalized']
, you’ll now have or_groups.makemodel[0].fields['general.make.normalized']
. The [0]
matches your Or Group Clause. You’ll see that in the first clause the returned models are BMWs, whereas in the second clause the returned models are Audis.
So now for each of your user’s selections you’ll have an Or Group Clause with its own list of items for the dropdown. In this example the make dropdowns are the same, but that might change if you add more fields to your Or Group, like for example the type. If someone searches for an Audi A3 Sport, the makes dropdown will be reduced to only show makes that have vehicles with Sport in their general.type.name
.
"or_groups": {
"makemodel": [
{
"fields": {
"general.make.normalized": [
{ "key": "alfaromeo", "display_value": "Alfa Romeo", "count": 111}
...
],
"general.model.normalized": [
{ "key": "bmw/1series", "display_value": "1 Serie", "count": 204},
…
]
}
},
{
"fields": {
"general.make.normalized": [
{ "key": "alfaromeo", "display_value": "Alfa Romeo", "count": 111}
…
],
"general.model.normalized": [
{ "key": "audi/a1", "display_value": "A1", "count": 215},
…
]
}
}
]
}
While building this, also keep in mind that you should only request general.model.normalized
after a make has been selected. (Otherwise we send the enormous list of all models of all makes to each visitor.) So one possible flow would be:
- The user lands on your website and you request
/dropdowncontents?_fields=makemodel[0].general.make.normalized
. - The user selects BMW and you add
&_fields=makemodel[0].general.model.normalized&makemodel[0].general.make.normalized=bmw
to your request. - The user selects 1-series and you add
&_fields=makemodel[0].general.model.normalized=bmw/1-series
to your request. - The user clicks that they want to search for a second make and you add
&_fields=makemodel[1].general.make.normalized
to your request. - The user chooses Audi and you add
&_fields=makemodel[1].general.model.normalized&makemodel[1].general.make.normalized=audi
to your request. - The user chooses A3 and you add
&makemodel[1].general.model.normalized=audi/a3
to your request.