Ehsan Akhgari wrote:

> Another solution is make the db believe your text is English.
> This could be done by "romanizing" the text before inserting it to the db,
> and converting it back to Unicode after reading it from the db and before
> displaying it to the user.  This can be done by choosing a Roman letter for
> each Persian letter, and reading Persian characters one by one and looking
> them up in a conversion table and writing the equivalent Roman characters to
> the output.  However, this has the downside that IIRC MySQL's full-text search
> is case-insensitive, and if I'm right in that you'd have to choose Roman
> characters all from one case (upper or lower.)  In addition to that, the data
> stored in the db might be difficult/impossible to use without such a conversion.
> It's you who ! should judge the tradeoffs before choosing to use this method or
> not.
Dear Ehsan,
You suggested a creative solution. Thank you.

My application, consists of a database, and two user-interfaces.

The first UI is used for data entry,
where I parse a given XML file, extract and "Romanize" its
data - based on a "Persian-Roman Conversion Map" -
and then insert them into DB.
Luckily, PHP provides a very fast function for
such conversions, named strtr().

Now I have a "Roman DB".

The second UI is used for data retrieval (searching),
where I "Romanize" the given search argument,
and look for it trough the DB records. The results will be
decoded and converted to Persian, before sending to stdout.

There are two disadvantages concerning this method:
- Firstly, as you pointed out, it is impossible to use the data without the coversion. How! ever, I can develop "phpMyAdmin" to handle this and simplify data manipulation for the client.

- Secondly, Romanizing adds a few overhead to the system. But while there only 10 records to be retrieved and displayed each time, this overhead doesn't make sense. In addition, PHP's strtr() function works fast enough.


I think, your solution is the only MySQL 4.0-friendly version to implement FULL-TEXT searching for Persian (well, that's not Persian, the Roman ;-) )

Once again, thank you for sharing your knowledge.

Yahoo! Personals
Single? There's someone we'd like you to meet.
Lot's of someone's, actually. Try Yahoo! Personals
PersianComputing mailing list

Reply via email to