I want to change minimum character length for search from 4 to 1.
I found this documentation https://doc.osclass.org/Fine-Tuning_MySQL_Full-Text_Search_-_Improving_search about osclass.
The thing is that, from the databases I use on my host, only this one has this 4 character limit, the rest of them have 0 or not set.
So I need to modify this ft_min_word_len=4
to `ft_min_word_len=1′ ONLY in the osclass database.
Can someone help with a sollution? I have access to cpanel and phpMyAdmin
2
Answers
It turns out that, from my scripts, only osclass uses this ft_min_word_len=4 variable from the server.
So I can't change it because I have a shared server host, and the providers won't change it because of that.
Turns out that there is another way to avoid changing this variable.
I write this answer here because I wouldn’t have been able to figure it out by my own without the help of others that shared information on forums ( https://forums.osclass.org/development/i-am-not-able-to-apply-a-regex-item-title/ or https://forums.osclass.org/general-help/brilliant-3-letter-word-search-is-possible!!!-read-this-tip/).
So here goes 2 days work:
The ideea is to filter the title and description of items before adding it to the database. This filter must add ‘_’ for every letter missing from a less than 4 letter word.
For example:
e___
ex__
exa_
For this to happen we need 2 functions:
addunderline($t) and removeunderline($t)
The ideea is to turn all the words with less than 4 characters from title, description and search pattern, to min 4 character words using underscore characters.
So, in the database there will be words like “e___” etc.
Then, when the information is displayed we use removeunderline function.
Please do a back-up for your files before starting!!!
Follow these steps
For Osclass 3.7.1 and Bender theme:
Stop and analize the code before copy-pasting it. I’m a human and error can happen, as I made the below instructions after many modifications….
1.
/oc-content/themes/bender/item-post.php
Replace
with
and
with
Replace
with
and
with
/oc-content/themes/bender/item.php
Replace
with
and
with
4.
/oc-content/themes/bender/search.php
Replace
with
5.
/oc-includes/osclass/helpers/hSearch.php
After:
Add this:
6.
/oc-content/themes/bender/search-sidebar.php
Replace
with
7.
/oc-includes/osclass/controller/search.php
Replace
with
8.
/oc-content/themes/bender/functions.php
Add to the end of the file (do not leave empty lines at the end of file)
9.
/oc-includes/osclass/classes/Breadcrumb.php
Replace
with
NO NEED TO MAKE THESE CHANGES[the ones below with osc_item_title()] IF YOU MAKE THE MODIFICATIONS FROM POINT 13!
and all
with
10.
/oc-content/themes/bender/common/head.php
Replace
with
11.NO NEED TO MAKE THESE CHANGES IF YOU MAKE THE MODIFICATIONS FROM POINT 13!
/oc-content/themes/bender/loop-single.php
Replace all
with
and
with
12.NO NEED TO MAKE THESE CHANGES IF YOU MAKE THE MODIFICATIONS FROM POINT 14!
/oc-content/themes/bender/loop-single-premium.php
Replace
with
and all
with
13.
/oc-includes/osclass/helpers/hItems.php
Replace
with
and
with
14.
/oc-includes/osclass/helpers/hPremium.php
Replace
with
and
with
End.
Now you must edit and save al the listings from your website or wait for all the listings to be edited and saved by their autors.(or regenerate the fulltext search tables in DB – you can find details about that online).
Obs.
This makes:
– urls, item_titles and item_description remain with underscores in automatic generated emails ,
– urls remain with underscores in seo friendly urls
– item_title and item_description remain with underscores in osclass admin area(only for admin, not for signed in users).
-words like bmw x5, become bmw_ x5,_ in the database, so you need to make modifications to add and remove underline functions to solve punctuation problem, without using <> characters in regex, because osclass transforms them into <; and >; and if the item gets edited and saved those characters are beeing multiplied with each edit-save action. I resolved this with an obs. for users not to use <> characters.
EDIT.
The item link can be resolved like this:
/oc-includes/osclass/helpers/hDefines.php
put
instead of
For {ITEM_TITLE} and {ITEM_DESCRIPTION}:
/oc-includes/osclass/emails.php
Put removeunderline() at {ITEM_TITLE} and {ITEM_DESCRIPTION} values.
Example:
Do the same for all {ITEM_TITLE} in this file (10 replacements).
Do the same for all {ITEM_DESCRIPTION} in this file (3 replacements).