Categories

searching for substrings

☆☆☆☆☆ No ratings yet
inhahe: ok, i index the sentence "i eat beans", the photo id is 32 inhahe: and we're starting with autonumber 0 for our table inhahe: it makes the records: inhahe: (0, i, null, 32) inhahe: (1, <space>, 0, 32) inhahe: (2, e, 1, 32) inhahe: (3, a, 2, 32) inhahe: (4, t, 3, 32) inhahe: (5, <space>, 4, 32) inhahe: (6, b, 5, 32) inhahe: (7, e, 6, 32) inhahe: (8, a, 7, 32) inhahe: (9, n, 8, 32) inhahe: (10, s, 9, 32) inhahe: well let's first say the person searches for "eans" inhahe: they'll do a search for a record n where n.letter=s and n.fromid.letter = a and a.fromid.letter = e inhahe: (however you do that in sql syntax) inhahe: n.photoid will point you to the photo that contains 'eans' inhahe: and the way this method works, that search will return all photoids that contain "eans" inhahe: now we index letter, fromid, and autonumber. inhahe: and here's something else we can do to make it faster inhahe: add two more fields inhahe: an enum indicating which field of the photo it occurs in inhahe: and an index to where it occurs in the field inhahe: that way your php doesn't have to do any searching -- the other method is to not have a letter field, and have each record have 256 entnies. fields for letters that don't exist to point to would be null. while this means more fields per entry, there would be fewer entries. this also implies doing the indexing differently