Advanced filtering for filter engine

Is it possible to make a filter engine where it can filter content from different databases in one field? My current filter engine can only filter stuff from one database (https://paxaurora6.editorx.io/aurora. We want to make a filter engine where it can look through multiple databases so our users don’t have to search through 10 different pages to find the thing they are looking for.

Please help me, I want to make this a thing before March.

Thank you!

Yes everything is possible.
Yes, everything is possible, but that will take some programming work.
In your case, your request goes beyond a helping-situation and is turning into a SERVICE.

But anyways i will give you some tips.

How to generate a dynamic-multi-filter?

  1. I would suggest you to work with - → Wix-Data (do not include any datasets into your project), if you want to generate a totaly dynamic and free of any boundary filter-engine.

  2. Also i would suggest you to generate your filtering-engine on - - > BACKEND, why???
    a) Better performance.
    b) More security for your data.
    c) Less code on your frontend, which would make coding more difficult and decreace a good overview of your code.

  3. There are different ways of how to generate your filter and also different levels of how DYNAMIC your filter-engine will be at the end.

I myself, at current time am using just one Mega-Query for almost everything and in almost every usecase.

  1. I would suggest you to generate a similar query, which is able to switch over different DBs → fully automaticaly.

I am working currently on such an MEGA-QUERY - → called → iQuery (intelligent-query).
If you want to get more information about that running project, you can contact me.

Ok, back to your problem…
Normaly all you have to do is to feed your query on the backend with the right data from your frontend. On backend you do the queries and filterings, or what ever else you want to do. The backend then sends desired data back to frontend.

Some example… (just some ideas, not a working solution!!!)

import wixData from 'wix-data'
import { getData } from 'backend/xxxxxxxxxxxxx.jsw'

$w.onReady(()=>{
    
    $w('#mySTARTbuttonIDhere').onClick(()=>{
        start_FilterEngine();
    });
})

async function start_FilterEngine() {
    let query = []
    let myCollections = ["Collection1", "Collection2", "Collection3"]
    let FIELD1 = "field1", let VALUE1 = "value1"
    let FIELD2 = "field2", let VALUE2 = "value1"
    let FIELD3 = "field3", let ARRAY3 = ["value1", "value2", "value3"]
    
    
    let res = getData(myCollections, FIELD1, VLAUE1, FIELD2, VALUE2, FIELD3, ARRAY3);
    console.log(res);
}

BACKEND:



export async function getData(collections, FIELD1, VLAUE1, FIELD2, VALUE2, FIELD3, ARRAY3) {
    return Promise.all([
    query(collections[0]).limit(1000).eq(FIELD1, VALUE1).find(),
    query(collections[1]).limit(1000).contains(FIELD2, VALUE2).find(),
    query(collections[2]).limit(1000).hasSome(FIELD3, ARRAY3).find(),
    ]).then((res) => { return res })
    .catch((err)=>{return err});
}

Just to give you an approximative example-code-skeleton.

UPGRADE AND EXPAND the example and generate your Multi-Filter!

Good luck!

You got response.

@russian-dima Gratsì. I’ve responded as well.

1 Like

I don’t know what your database structure is, however, instead of having multiple collections to categorize items, I would suggest trying to use just one DB collection. You can add a category field, or fields for that matter, which will enable you to filter and search your data. By using one collection, your searches will be much more streamlined and efficient. Also, instead of having to change your code when you add additional collections, all you’ll need to do is add items with the category field set to the new type of data.

Great suggestion Yisrael.
As I always say → it all depends on your database structure, that’s right!
But this is also exactly the point to generate a new query-generation :smiling_imp: