Advertisement:

Author Topic: 2 character minimum in search  (Read 30455 times)

Offline GunSlingerBoy

  • Newbie
  • *
  • Posts: 1
2 character minimum in search
« on: June 23, 2012, 07:34:29 PM »
as an admin and a regular user on several SMF's this annoys me when i have to omit characters like "a" and numbers and such when they are critical to finding the posts and or threads

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: 2 character minimum in search
« Reply #1 on: June 23, 2012, 07:39:58 PM »
They're not critical. In almost every case such really common words are automatically excluded, even when SMF doesn't have complete control over it.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,609
  • Gender: Male
    • Kindred-999 on GitHub
Re: 2 character minimum in search
« Reply #2 on: June 23, 2012, 11:47:17 PM »
That request is just plain silly....

how is "a" critical in a search?

searching for "treatise petunias" will bring up the post with the title or contents: "A treatise on petunias"

searching for just "a" would bring up nearly every post....

Even google excludes words like "a" and "an"....
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

MrPhil

  • Guest
Re: 2 character minimum in search
« Reply #3 on: June 24, 2012, 11:58:43 AM »
A word that is a single letter or even two letters is usually considered just "noise" and should be ignored. If it's something important to look for as part of a phrase, put it in quotation marks: "i have to omit".

kat

  • Guest
Re: 2 character minimum in search
« Reply #4 on: June 24, 2012, 12:00:43 PM »
Quote from: Kindredlink=topic=479967.msg3359266#msg3359266 date=1340509637
That request is just plain silly....

Funnily enough, I agree with GunSlingerBoy, totally.

If you're searching for certain pieces of code, as I sometimes do, here, it's a pain in the arse. :P

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: 2 character minimum in search
« Reply #5 on: June 24, 2012, 12:02:01 PM »
Even then most systems actually omit it anyway. Certainly Sphinx does by default (min length 3), MySQL FULLTEXT does (min length 3), and IIRC even a SMF custom index has a minimum length of 3 as well.

I can't imagine a piece of code that would meaningfully be found with a couple of characters either...
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

kat

  • Guest
Re: 2 character minimum in search
« Reply #6 on: June 24, 2012, 12:13:34 PM »
For a coder, it's probably easier, because you'll know which bits can be omitted, without it affecting the result.

Us mere plebs don't have that advantage. :P

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,609
  • Gender: Male
    • Kindred-999 on GitHub
Re: 2 character minimum in search
« Reply #7 on: June 24, 2012, 06:12:17 PM »
I re-state.....

how is "a" critical in a search?

searching for "treatise petunias" will bring up the post with the title or contents: "A treatise on petunias"

searching for just "a" would bring up nearly every post....

Even google excludes words like "a" and "an"....
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

kat

  • Guest
Re: 2 character minimum in search
« Reply #8 on: June 25, 2012, 06:53:39 AM »
You misunderstand me... (Not surprisingly) :P

What I mean, is when you get a quoted error message, you often get single characters. Especially if that message contains ">", "/", "a=" and the like.

If you copy that error and paste it into "Search", you get that bloody annoying error and a non-coder won't know which characters to omit.

I get around it, myself, by using the "Site search" thingy, on Google (Or whatever).

Does that make more sense?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: 2 character minimum in search
« Reply #9 on: June 25, 2012, 07:11:32 AM »
Most of those characters won't be searchable anyway... all the search backends discard non word characters to some degree, some more than others.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

kat

  • Guest
Re: 2 character minimum in search
« Reply #10 on: June 25, 2012, 07:17:46 AM »
Yeah, I realise that. But, if you perform such a search, it would be good for it to just get on with it and not respond with that damned annoying message.

Can you see where I'm coming from?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: 2 character minimum in search
« Reply #11 on: June 25, 2012, 07:20:29 AM »
I can, except that experience suggests it won't pan out like that anyway.

What would be the point of not throwing the error, only to return with no responses, or worse, so many irrelevant responses?

Human time is not cheap, and invariably you're being kept at bay from having many many many pointless searches to wade through.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

kat

  • Guest
Re: 2 character minimum in search
« Reply #12 on: June 25, 2012, 07:32:33 AM »
Well, you have more knowledge about how these things work than I do, obviously.

I just saw the original post and thought "Yeah! That pisses me off, too! I wonder if something couldn't be done, to improve that!" and that was that. Would, perhaps, an option to "Search exact term/phrase" improve that, assuming the single/double character was circumvented, work better, for that kinda thing?

(As you know, I know diddly-squat about all this coding stuff. I'm just kinda tossing things around, to see if such things could work and are practicable.

If, as Kindred seems to be implying, I'm talking total bollox (He may well be 100% correct, obviously), because it just ain't possible, I'd be fine, with that, as long as what you're saying's impossible, is what I actually mean to be asking for. (I'm not the best at expressing such things, as you may have noticed)

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: 2 character minimum in search
« Reply #13 on: June 25, 2012, 07:41:04 AM »
Well, it isn't exactly possible, that's sort of the point.

Of the 4 methods of searching available for SMF, 2 of them will forcibly remove non word characters entirely and will strip words of one or two letters as well, and dealing with this is not something SMF can do, we're talking reconfiguration on a nasty technical level. (And one of these methods also comes with a very large list of words it will ignore anyway, of which things like 'the' are auto-excluded even though they're not 2 letters)

Of the other 2, that's a bit more fixable, but there are much greater issues at stake here.

Humour me. Do a search here on 'sp'. That's SimplePortal, right? Or not, as a search will quickly tell you. And therein lies the problem: possible or not, the 2 character minimum is there to prevent you getting flooded with many many many more results than you actually want or need.

As far as phrase matching goes, you're still sort of stuffed because the search backends aren't smart enough to cope with that properly (except Sphinx, and *maybe* MySQL FULLTEXT though that's way too slow to be usable anyway), so it still wouldn't solve your problem anyway without a total rewrite of the search system.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

kat

  • Guest
Re: 2 character minimum in search
« Reply #14 on: June 25, 2012, 07:52:26 AM »
I can see your point. Especially about the "SP" thing.

But, with the facility to "Search exact phrase", would that, particularly with error message searches, obviate that?

If it could be done, so that "Exact term/phrase" mean exactly that and nothing else, at all, would that be a possibilty?

If I search for "A brown kitten" and expected just that and NOT "brown kitten", could that happen?

Offline emanuele

  • SMF Super Hero
  • *******
  • Posts: 14,156
  • Gender: Male
  • THERE'S JUST ME
Re: 2 character minimum in search
« Reply #15 on: June 25, 2012, 08:09:52 AM »
K@ have you tried using the double quotes around the exact phrase?
http://www.simplemachines.org/community/index.php?action=search2;search="A brown kitten"


Take a peek at what I'm doing! ;D



Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: 2 character minimum in search
« Reply #16 on: June 25, 2012, 08:10:14 AM »
That's the point, it won't at all.

IIRC, with the exception of unindexed, the 'a' in 'a brown kitten' won't even be matched in the first place, so it won't get into the pass of tokenisation to match against phrases.

OK, search engine theory time. This is, broadly, how all of the search backends (except unindexed) work.

You start off going through all the posts, looking for sequences of words, a word being defined as multiple word-characters joined together. You store each of the words you find and the position in which you found them. Thus, you have your index - a list of words, a list of the positions they were in and the posts that contain them.

When you perform a search, you do the same thing: you break the search query up into groups of word-characters, before looking those up in your big list of words.

Matching words on their own, then, is simply a case of looking them up in the index and seeing which posts match the most words together.

Matching phrases is much the same except that you're looking for words in the same post and in contiguous positions.


This is how, ultimately one would match 'brown kitten'. But the 'a' will have been dropped long before it makes it into the index. Meaning that even if you could ignore the two-character requirement, there is no way to actually find it in the index, because it's not there.

In essence, when you search for 'a brown kitten', it's internally being parsed to 'brown kitten' before it gets thrown at the index.

Now, you can relax the rules around how indexes are built, sure, you can alter the criteria for what a word is and what 'word characters' are, how many letters etc. However, you need to go round and rebuild the index (which for any sizeable forum is a LARGE task), assuming it's even possible (MySQL FULLTEXT, I'm looking at you) and assuming that the word you're searching for is even going to be matched ('a' will be excluded by MySQL FULLTEXT even if you change the minimum word length there because of its commonality)

If you do decide to relax these restrictions, you will - guaranteed - have more white noise coming back in searches, for a vague and possible improvement to phrase searching. Even though it's still broken by the various mashing that goes on to deal with escaped characters, accented characters, inline bbc etc...
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

kat

  • Guest
Re: 2 character minimum in search
« Reply #17 on: June 25, 2012, 08:24:27 AM »
K@ have you tried using the double quotes around the exact phrase?
http://www.simplemachines.org/community/index.php?action=search2;search="A brown kitten"

I have, yeah. It still abhors single characters, if I remember rightly. :(

Thanks, for that, Pete. I'd assumed that that's how they worked, kinda.

What I was wondering, probably in an "Ideal world" scenario, is whether it could be made, so that if you selected "Exact phrase", the indexer thingy would ignore other settings and look just for that exact phrase, regardless of what that phrase contained, and nothing else.

Or, am I living in Cloud Cuckoo Land?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: 2 character minimum in search
« Reply #18 on: June 25, 2012, 08:36:38 AM »
That's broadly how it works in the unindexed scenario, which doesn't have such an index but just goes through, brute force, looking for things. But as you can imagine, it's *slow*.

Which is why you build indexes that can be searched much more quickly. But the search system and the indexer have to work the same way otherwise the effort of building the index is wasted.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

kat

  • Guest
Re: 2 character minimum in search
« Reply #19 on: June 25, 2012, 08:45:54 AM »
Ah, yeah. The old speed consideration.

Lots to search through, here, I s'pose.

I'll have to stick with the ol' site search, then, ay? :)