php - Search feature for my site -
I need to add a search feature to a site that I am creating and thinking that anyone has Have done something.
I have a sample table in which the description of cats is in this format:
name, location, type, age, gender and size And I have only one search box where users can enter their search terms My question is, how do I find the table, for example if there is a type of "cat in Paris"? I want to find all fields and if I find anything, I would like to return.
Is there a way to achieve search criteria rather than keeping several boxes? Any help or suggestions would be appreciated.
In this situation it works very easy to do a complete search in Mysql Can index a natural language search
If you had a mysql table with the following schema, the cats:
mysql> Leave cats; + -------- + -------------- + ------ + ----- + --------- + - - ------------- + | Field | Type | Faucet Key | Default | Extra | + -------- + -------------- + ------ + ----- + --------- + - - ------------- + | ID | Int (11) | No | PRI | Faucet Auto_interpretation | | Name | Varchar (100) | Yes. Child | Faucet | | Place Varchar (100) | Yes. | Faucet | | Type | Varchar (100) | Yes. | Faucet | | Age Int (11) | Yes. | Faucet | | Gender | Varchar (100) | Yes. | Faucet | | Size | Varchar (100) | Yes. | Faucet | + -------- + -------------- + ------ + ----- + --------- + - - ------------- + You can run the following SQL to create the index:
Create full INDEX cats But cats_search (name, type, location, gender); Then when you receive the search string 'Male tabby in Paris', you can find the table with this SQL:
SELECT *, Match against MATCH (name, type, place, gender) ('Male in Paris in Boolean mode') Beats related relevance Where (match, name, type, gender) match against ('male tabby in Paris in BbN mode') Relevance Order By Deassc; will return all those rows that match those words, in order mysql is most relevant.
To correct the results, you must research mysql full text searches, the way you want it, but you should remove it from the ground.
Comments
Post a Comment