I m having little confusion using MySQL fulltext. I have database whose charset is set to utf-8 and collation set to utf8_unicode_ci
I have following flow of searching products. User chooses from the flow below to search any product
- user selects product_type, enum field with value consumable/unconsumable.
- Then selects product_nature, enum 0=>finished 1- unfinished.
- then user selects location, varchar User may select multiple location.
- then user specifies price ranges
and so on (about 5 more selection)
In search page the only thing users types is, location, price ranges. Rest all they select from combo.
My confusion is.
- Does my database supports FULL Text Search?
- What are the fields I need to index for enabling full text search.
- As full text is supported in
varcharandtextdatatype field only. How to get relevant results if many fields user selects for filter is inenum - I want to show exact match at top and nearly matching products depending upon the filters user selects like I described above. Does order by fulltext relevancy work here because there are many fields which are of type
enum.
Edit
For better understand for example
This search is for those specially who knows what to buy but doesn’t know anything else. Like I need a Mobile PHone, but I don’t know anything else, I just select its type(Wifi/without wifi) from combo, I then select camera (with/without), I then select other few features like this. I then specify price range I can afford, I then want phone available in store in particular location. For this I type location A, location B, location C. I want results based on either of these location. And I want to order results according to the nearest match of the search parameter specified. Exact match to nearest match, then least nearest match. Hope this helps
Can anybody throw some light on this?
Thanks
The documentation on the
Full-Text Search Functionspagestates that
FULLTEXTcan only be used with MyISAM, however, MySQL 5.6 added support for theFULLTEXTindex with InnoDB (seeSection 14.2.4.12.3on theInnoDB Table and Indexpage). If your table(s) are setup as MyISAM, then yes – you should have support; with InnoDB, potentially – pending on your MySQL version.To enable the full-text search, you should add a
FULLTEXTindexonly on the fields that you’re going to use the search on (no point
to add it to fields you won’t). A
FULLTEXTindex can only beapplied to
CHAR,VARCHAR, andTEXTcolumn-types, so that maybe a start. Your product names may be too short to worry about a
FULLTEXTindex (consider maybe a HASH index instead), but yourproduct descriptions (if you have them) would be really good for it.
enumdata is good to index with aBTREEindex, not aFULLTEXTone.
Not sure; could you post an example of which fields would be queried
and ordered and their data-types to give a better image as to what
you need?