E
E
Eugene2017-04-15 18:31:52
PHP
Eugene, 2017-04-15 18:31:52

How to make a combination search?

We need a search algorithm (and ideally a script). There is a product filter on the site. Each combination of attributes has its own url. These urls need to be generated.
We have: a list of attributes for each product, some attributes have multiple values ​​\u200b\u200b(for example, LED, led, diode), the maximum number of attributes that can be selected, the attributes must have a clear sequence in accordance with the sort order (that is, from LPO 36W and 36W options LPO will only have 1 option)
At the moment, a product has an average of 15-20 attributes, a maximum of 5 can be selected, the total number of attribute values ​​\u200b\u200b(taking into account the multiplicity is 20-40.
I tried to parse the site, all programs give out of memory after a couple of weeks.
There was an idea to take each product, form combinations for it, write it to the database excluding duplicates, but 90% of the combinations from product to product will be repeated and this is just a waste of time.
It can just take all the unique attributes, sort through all the combinations (for example, 100 attributes, a maximum of 5 can be selected at the same time, I don’t know how to calculate the number of combinations) then check if there is a product with such a combination (I don’t know how to do this not through the database, and through the database, queries will be processed for 0.5 seconds).
Help not to get out of memory and, if possible, save time.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Artamonov, 2017-04-15
@ArtamonovDenis

Why preform the url for each combination?
As far as I understand, you need to make a selection of goods depending on the selected attributes, i.e. filter
Filter = form
Each attribute = checkbox/input/select
Marked attributes
Submit form-filter
PHP catches the GET/POST array and looks at which attributes were marked, depending on this it generates a link and/or return the result from the database
In any case, you need to store information somewhere and process it depending on the filter
. If there are not many products, then you can create a js-object when starting the page with products and already work with it
. Or work with the database and set up caching, then the same requests will not be subtract 0.5 sec

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question