Plus Minus feature in searchbox

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Ideas Centre
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
MaFeSa
Registered User
Posts: 175
Joined: Wed Feb 11, 2009 7:48 am

Re: Plus Minus feature in searchbox

Post by MaFeSa »

Incredibible guys, this problem is still present on 3.0.10 :o
User avatar
AmigoJack
Registered User
Posts: 5958
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Plus Minus feature in searchbox

Post by AmigoJack »

No, it's resolved since 3.0.8. Don't forget to use quotes for such searches (Anne-Sophie are two keywords, ending up in +Anne -Sophie, whereas "Anne-Sophie" is really only one keyword - proof).
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
MaFeSa
Registered User
Posts: 175
Joined: Wed Feb 11, 2009 7:48 am

Test-123

Post by MaFeSa »

Sorry tried now on localhost with WAMP but alway no results :cry:
Tried with native search and mysql with all index
User avatar
AmigoJack
Registered User
Posts: 5958
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Plus Minus feature in searchbox

Post by AmigoJack »

That's only your opinion. Tried it locally on 3.0.10 and got results where expected (using MySQL FULLTEXT, quotes around my keyword). You must be doing something wrong and without further details I can't point at the possible culprits.

Also be aware that you won't find your own post when issuing "Test-123" for the topic search, as that search only respects the post texts, not their subjects.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
MaFeSa
Registered User
Posts: 175
Joined: Wed Feb 11, 2009 7:48 am

Re: Plus Minus feature in searchbox

Post by MaFeSa »

AmigoJack wrote: Also be aware that you won't find your own post when issuing "Test-123" for the topic search, as that search only respects the post texts, not their subjects.
ok, I found the problem :roll:

Many thanks!
MaFeSa
Registered User
Posts: 175
Joined: Wed Feb 11, 2009 7:48 am

Re: Plus Minus feature in searchbox

Post by MaFeSa »

e.Rock wrote:This will negate the inclusion/exclusion functions of the search, but my band-aid solution was to modify root/search.php to include this line (sometime after $keywords is assigned):

Code: Select all

$keywords = str_replace('-', ' ', $keywords);
This effectively converts the "temp-table" search string to "temp table".

With some more time, this could be improved to only work on "string-string" instead of "string -string" or "-string", but our needs lean much more towards recognizing hyphens in the string than being able to exclude a string from the search.

If anyone is better at regexps than me, please feel free to contribute a "better" solution.
Thanks, your solution is working very well on my new forum where I can't use MySQL FULLTEXT.
MaFeSa
Registered User
Posts: 175
Joined: Wed Feb 11, 2009 7:48 am

Re: Plus Minus feature in searchbox

Post by MaFeSa »

Hi,
I converted another forum from MyBB to phpBB (thanks for this great software) and now I have the same problem... all index are made but I have problems searching words like dd-wrt, bcu-126, WZR-HP-G300N
I'm freaking out because with mybb was working perfectly :(

There is a way to make sure that dd-wrt is considered as one word and not as dd -wrt?
Now I'm using Fulltext mysql and even if I use the " " I do not get results!

Some examples of searches:
"dd-wrt" -> No results
"wrt" -> OK
"WZR-HP-G300N" -> No results
"G300N" -> OK

PS. Same problem also on area51: https://area51.phpbb.com/phpBB/viewtopi ... 7&p=252399
User avatar
AmigoJack
Registered User
Posts: 5958
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Plus Minus feature in searchbox

Post by AmigoJack »

That's difficult to analyze, since phpBB.com uses Sphinx here and there instead of FULLTEXT MySQL. Also different DMBS installations can have different settings - one requires you to have at least 4 characters whereas another will let you search also with 3 lettered words. Combined words (dd-wrt, bcu-126, one-two-omg-lol...) still have this limitations: all components which have not enough letters are trimmed entirely. So make sure your settings are compliant and which phpBB version you're using.

MySQL itself doesn't care about non-characters, so you have to issue a search without operators, like anne.sophie or four.fingers and results will show up. Just as I wrote back in 2010.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
MaFeSa
Registered User
Posts: 175
Joined: Wed Feb 11, 2009 7:48 am

Re: Plus Minus feature in searchbox

Post by MaFeSa »

Thanks for your help :)
AmigoJack wrote:Also different DMBS installations can have different settings - one requires you to have at least 4 characters whereas another will let you search also with 3 lettered words. Combined words (dd-wrt, bcu-126, one-two-omg-lol...) still have this limitations: all components which have not enough letters are trimmed entirely. So make sure your settings are compliant and which phpBB version you're using.
MySQL is set to 3 words
AmigoJack wrote: MySQL itself doesn't care about non-characters, so you have to issue a search without operators, like anne.sophie or four.fingers and results will show up. Just as I wrote back in 2010.
OK, but why if I search on post_text or post_subject with phpMyAdmin I get results?
abc-123 -> OK
abc -123 -> Only "abc" results

Is possible do the same thing with phpBB?

Many thanks
MaFeSa
Registered User
Posts: 175
Joined: Wed Feb 11, 2009 7:48 am

Re: Plus Minus feature in searchbox

Post by MaFeSa »

Incredible, I tested now locally with wamp and phpbb2 and searches are perfect!
I find all words with "-" :o
User avatar
AmigoJack
Registered User
Posts: 5958
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Plus Minus feature in searchbox

Post by AmigoJack »

MaFeSa wrote:3 words
characters
MaFeSa wrote:phpMyAdmin
MaFeSa wrote:phpbb2
Both don't use FULLTEXT.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
MaFeSa
Registered User
Posts: 175
Joined: Wed Feb 11, 2009 7:48 am

Re: Plus Minus feature in searchbox

Post by MaFeSa »

OK thanks AmigoJack, so there isn't a solution?
:(

PS. With fulltext natives is possible?
User avatar
AmigoJack
Registered User
Posts: 5958
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Plus Minus feature in searchbox

Post by AmigoJack »

Open /search/fulltext_mysql.php and find:

Code: Select all

        // Filter out as above
        $split_keywords = preg_replace("#[\n\r\t]+#", ' ', trim(htmlspecialchars_decode($keywords)));
After, add:

Code: Select all

        /*** 2010-07-24 BEGIN AmigoJack
            Automatically enclose searches like "Anne-Sophie" into quotations marks, if they aren't already ***/
        if( $this-> pcre_properties ) {
            $split_keywords= preg_replace( '#(^|\s)([\p{L}\p{N}\'*()]+[^\p{L}\p{N}\'*"() ][\p{L}\p{N}\'*()]+)(\s|$)#u', '$1"$2"$3', $split_keywords );
        }    else 
        if( $this-> mbstring_regex ) {
            $split_keywords= mb_ereg_replace( '(^|\s)([\w\'*()]+[^\w\'*"() ][\w\'*()]+)(\s|$)', '\\1"\\2"\\3', $split_keywords );
        }    else {
            $split_keywords= preg_replace( '#(^|\s)([\w\'*()]+[^\w\'*"() ][\w\'*()]+)(\s|$)#u', '$1"$2"$3', $split_keywords );
        }
        /*** 2010-07-24 END ***/
It does what it says. If you're able to experiment on your local phpBB2 you can also test everything on a phpBB3.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
MaFeSa
Registered User
Posts: 175
Joined: Wed Feb 11, 2009 7:48 am

Re: Plus Minus feature in searchbox

Post by MaFeSa »

Thaaanksss, I was going crazy and you have saved me :D
Now:
abcd-1234 -> OK -> searched as "abcd 1234"
abcd -1234 -> OK

Is possible do the same thing also with fulltext natives?
Thanks for your help ;)
Last edited by MaFeSa on Wed Mar 27, 2013 9:08 am, edited 1 time in total.
MaFeSa
Registered User
Posts: 175
Joined: Wed Feb 11, 2009 7:48 am

Re: Plus Minus feature in searchbox

Post by MaFeSa »

Hi, I did some tests and it works great with Fulltext mysql!
Thanks again AmigoJack ;)

This fix should be added in the next version and also for Fulltext native!
Locked

Return to “[3.0.x] Support Forum”