Code for a Site Search to query the Title Field of all datasets

I’m using Wix Studio. I’m not a coder, and I sincerely apologize knowing that my need has probably been discussed multiple times, but I have failed to find it or simply don’t understand :grimacing:

I am developing a website that will contain pre-designed graphics in various social media post sizes for download. Currently, I am planning to break the graphics down into catagories based on their content. Each catagory will have a dataset linked to a list page for every graphic in that catagory and an items page for individual graphics. I want vistors to be able to run a search using a keyword. I want the search to query ALL Title Fields in ALL datasets along with the name of the List pages. I want the query to render the information into a repeater that contains the image of the graphic and the name of the graphic that then links to the individual item. If the keyword appears in the name of a List page, I just want the name of the page listed in the repeater and have it linked to the page it corresponds to. A photo is not necessary, but would be a nice bonus.

This might be asking for way too much, but I would also like to render a particular graphic only once. Some graphics will be contained in multiple datasets because they contain content that can be listed under multiple catagories. So if the keyword is ‘dog’ and I have a graphic with the Title ‘Dog Eating IceCream’ and that Title appears in 3 different datasets, I don’t want it to be rendered three times, just once. Geez, I hope I’m making sense.

I have tried the Wix Site Search App. It’s been very disappointing. I thought it might work for me, but it’s rendering items that I have deleted and discriptions that I don’t want. It’s a hot mess.

I can’t write code, but I do know enough to take a code and insert the names of elements that are specific to my website. I also kinda understand that to link datasets you have to set up reference fields, but I’m not sure I’m doing that correct either.

Thank you so much for taking the time to read and perhaps point me in the right direction.

devin

In your specific case, i would say you will need a CODE-generated SEARCH-ENGINE-SOLUTION.

If you are looking for a collaborating coder, i could take a look onto it and help you out…
—> velo-ninja@outlook.com
If you want to go your own way and do it on your own …

Here some examples…

  1. Add multiple Unique drop downs to a code - #12 by russian-dima
  2. Filter multiple options - #9 by russian-dima
  3. Want to "call" multiple items from database according to user selection. Can you help? - #13 by russian-dima

If you want to use DATASETS anyway…
4) Database filtering and grouping including caching of results - #3 by kenanuenal

By reading all those old posts, you can collect the neccessary knowledge of how to generate your own SEARCH-ENGINE driven by CODE.

Thank you! I’ll look over all of this and see what I can do.

So, I’ve watched lots of videos and read multiple articles, and I pieced together something that searches my database using a keyword, but not displaying as I want. I decided to make things as easy as possible, at least for now, and put all of my graphics into one database.

The code I have for my search and results page has a search bar, and it works as it should. The results are shown in a repeater. However, the code I found and used is connected to the dataset, so it shows all of the graphics in my collection prior to a search and then renders the specific search results. I don’t want to see all of the graphics. I want a blank page with a search bar to start with. I tried inserting a collapse code, but that works only after a search doesn’t render any results. I know this issue is because the code is connected to the dataset, but when I replace that with the name of my collection, it doesn’t work. Is there a way to make this code search the collection? Thank you for your time!

devin

import wixData from ‘wix-data’;

let debounceTimer;

$w(“#searchInput”).onKeyPress( (event) => {
if(event.key === “Enter”){

$w(“#clearbutton”).show();

$w(“#searchInput”).value;

if (debounceTimer) {
    clearTimeout(debounceTimer);
    debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
    filter($w("#searchInput").value); //ID of input form
}, 200);

}

let searchWord;

function filter(search) {
if (searchWord !== search) {
$w(“#dataset1”).setFilter(wixData.filter().contains(‘title’, search)); // ID of the dataset
searchWord = search;
}

}

$w(“#repeater1”).onItemReady(($item, itemData, index) => {
$item(“#text1”).text = itemData.title;
$item(“#mainImage”).src = itemData.mainImage;
$item(“#mainImage”).link = itemData[‘link-all-graphics-1-title’];

                if (itemData.title=== "N" ){
                    $w('#repeater1').collapse()
                }

}
,
)
})
$w.onReady(() => {

$w('#clearbutton').onClick(() => {

    $w("#searchInput").value = undefined
    $w("#dataset1").setFilter(wixData.filter())

    $w("#clearbutton").hide();

})

})