Answer the question
In order to leave comments, you need to log in
What is the principle of creating a filter in an online store that does not allow an empty result?
Good day.
Available:
Answer the question
In order to leave comments, you need to log in
This task does not fit well with a relational DBMS , which Sergey Gornostaev already wrote to you about. What you
are doing is faceted search. It is perfectly implemented by DBMS, which are able to so-called. full text search.
The fact is that to implement a full-text search, bit indexes are used, which, in addition to their main search task, allow you to immediately determine the number of "documents" included in the selection (according to the terminology: what is called "records" in relational DBMS is called "documents" in full-text search engines - such a tradition).
You, on the other hand, are using a relational DBMS that is not suitable for this task. And in relational DBMS, determining the number of records that got into the answer,.
Using a full-text search engine, you could apply filters simply to find out how many entries a response would result in, and then turn them off if there are too many entries. In full-text search engines, this is a cheap (fast) operation.
But in relational DBMS, and you use just such, this is a very expensive operation. And you can't do that. Unless, of course, you want your site to slow down.
One of the fastest full text search engines is SphinxSearch and its fork of Manticore.
PySy:
Why full-text search engines are ideal for faceted search implementation.
1) Search by name should still be on the site. A full-text search engine, unlike a conventional relational DBMS engine, can search by any part of the name, by product description
... ):
a) The phrase is divided into separate words, while auxiliary words (prepositions, conjunctions, articles, etc.) are discarded
b) Words are run through the stemming algorithm to cut off the endings snowball.tartarus.org/algorithms/russian/stemmer. html
c) The resulting words without endings (terms) are placed in the simplest storage of the "key-value" type, where the key is the term. The value is a large bit vector of type 00010101011110010000000011111....., where each zero and one position corresponds to a document (in your case, a product). For compactness, the representation RoaringBitmap roaringbitmap.org
is used
d) With the resulting bit vectors, you can extremely quickly perform any logical operations AND, OR, NOT
How is a faceted search based on a full-text index?
It's very simple, we introduce an artificial term "color = green", we build a bit vector on it; we introduce an artificial term "color = red", we build a bit vector on it; we introduce an artificial term "view=boot" and build a bit vector based on it; we introduce the term "view=boot" and build a bit vector based on it; we introduce the terms "size=40", "size=41", "size=42", "size=43" and build a bit vector for each of them.
After that, finding "size 42 green shoes" is just an AND operation on 3 bit vectors.
And once again - this is all done by the engine, you do not need to do this manually.
Offload the task of faceted search to some full-text search engine that is more designed for this than RDBMS.
They would take any engine and see why the BIKE should be reinvented?
There are intelligent filters in opencart, minishop2, and Bitrix.
Everywhere they are naturally paid ....
Although I’m probably in vain about Bitrix, this is not yours))))
Minishop - install the miniShop2 + mSearch2 package for free on demo servers, study it .
On the demo, just as you need - _minishop2.com/catalog/
Bitrix - install the demo version for free, look for a filter with a free demo installation - that's it! further a week or how much the developer of the filter will give there - rummage .
But opencart would seem to be free in essence, but you can’t just install the filter just like that, only prepayment))
Display, in addition to creations for this query, also suitable parameters for the filters themselves!
Here is how the variants of one “Collection” parameter look like without sorting by the “Brand” parameter
And here is how with the “Brand” sorting
There will always be fields in the filters that match others and there will always be at least 1 product
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question