-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get rid of code duplication between Autocomplete and Search #331
Comments
@duker33 Let's specify an issue we are going to solve here.
All backend logic is generalized in refarm-site, but frontend is uniquely implemented in each client site. |
@artemiy312 , i agree with most of the points, but i think that Bad
|
@duker33 >Good search.search will hide all data adapting inside It doesn't mean that we should fully rewrite it, I believe we should create a new abstraction, that will adapt data to needs. I worry that we will lose some features and get more bugs, but if you sure let's make like this |
@artemiy312 , Also we have enough resources to implement good arch. How we can move forward our arch discussion? That's my proposition: let's merge related PR with my arch version. And you'll propose another PR fixing my arch prototype with expreaded code comments. Let's move? |
@duker33 >So, we can throw away current search realization in favor of much more ready and clear django qs based search. Django qs search uses full-text search, in our case it is postgresql full-text search. Trigram works only with textual data, so we have to determine the type of searched fields to provide ability to search by non-textual fields too. For those non-textual fields we are using our custom search function. All it does the current implementation, so we can't simply throw away it We should document this |
@artemiy312 , trigram is implemented at postgres side too.
I'll repeat myself: we have no data if current search algo is working or not. Maybe simple name__search will make more good UX then current algo. |
@duker33 >We can choose algo like this. It can solve the problem i think: We already have implemented this algo in I believe it will be enough to rewrite |
@artemiy312 , let me fix example =)
We also can use sorting by SearchRank and so on. Generally speaking our task consists of two parts: 1. Search engine
We can relatively easily rewrite it in one queryset. If you don't believe it, just let me continue working with code. 2. Results list I proposed a way to do it. It's definetily not the most perfect. But it's much more good then simple geterogeniouos list merging with no interface and contracts. |
You provided the code that uses full-text search. As I said before, full-text search doesn't support fuzzy search, it doesn't handle any typos in a search query. Also postgres can't combine the full-text search with trigram
I have concern about the heterogeneous list too, but if we will make it homogeneous we have to produce such template: {% for r in results %}
{% if r.name %}
{{ r.name }}
{% endif %}
{% if r.price %}
{{ r.price }}
{% endif %}
{% if r.specification %}
{{ r.specification }}
{% endif %}
and so on
{% endfor %} It looks unclear to me. Things will get worse, when we add markup. I'd prefer to use {% if results.products %}
{% for p in results.products %}
{{ p.name }} {{ p.price }} {{ p.category.name }}
{% endfor %}
{% endif %}
{% if results.series %}
{% for s in results.series %}
{{ s.name }} {{ p.specification }}
{% endfor %}
{% endif %} But it seems a matter of taste, so it will up to you. |
@artemiy312 ,
It doesn't clear to me why postgres can't mix trigram with the common search. On django QS level trigram is just another query filter (trigram_similar) or can be used with
It's true, but trigram has pros too. I'll not going cover them - it's for the separated task. But in general, we should be able to combine different techniques for different content: trigram/search/like.
It's true problem. To solve we can provide good default empty values at Result class. This code will be much more clear since it will use class instantiation. Let me generalize the question you've shown: Should search template know about results nature or not? |
i close the discussion. We'll continue it at sub issue's PR. We'll discuss more concrete code proposition |
Now configuring Search and Autocomplete search_entities list leads to different results.
But they should be identical
The text was updated successfully, but these errors were encountered: