How to use Grammar in MySQL.
MySQL has better Content Management aspects and handles bulk data efficiently
Assume data is loaded into a Table of MySQL
Let us consider a table called CORE_DATA which contains the following columns,
Identifier -- A Unique identifier for the row
SentDate -- Worked date
Content -- Actual text message, Can be a LONGTEXT or MEDIUMTEXT
Summary -- Header or the topic of the text message
CREATE FULLTEXT INDEX content_idx ON hoot_data(content);
MATCH --A keyword to search a string literal
The below Query just gives all the rows which matches a string
(select 1 PrioID,summary,content from CORE_DATA
where upper(CONTENT) LIKE
upper(CONCAT('%', 'Deepika Padukone is awesome' ,'%')) limit 100 )
--- A complete Match
union
(SELECT 2,summary,content FROM CORE_DATA WHERE MATCH (content)
AGAINST (replace('Deepika Padukone is awesome', ' ' , ' +')
IN BOOLEAN MODE))
--- A complete Match with ALL words present at different PLACES of the column
union
(select 3,summ,cont from
(
SELECT summary as summ,content as cont, MATCH (content)
AGAINST (replace('Deepika Padukone is awesome', ' ' , ',')
IN BOOLEAN MODE ) ---
--- A partial Match with ANY one word present at different PLACES
AS score FROM HOOTSEARCH.HOOT_DATA) q1 order by score desc limit 100)
order by PrioID
Result set:
Deepika Padukone is awesome -- Result of 1st Union clause
Deepika last name is Padukone and she really look awesome -- 2nd Union
Deepika acted in Ramleela and looking like an angel and her costumes are really nice --3rd Union
MySQL has better Content Management aspects and handles bulk data efficiently
Assume data is loaded into a Table of MySQL
Let us consider a table called CORE_DATA which contains the following columns,
Identifier -- A Unique identifier for the row
SentDate -- Worked date
Content -- Actual text message, Can be a LONGTEXT or MEDIUMTEXT
Summary -- Header or the topic of the text message
CREATE FULLTEXT INDEX content_idx ON hoot_data(content);
MATCH --A keyword to search a string literal
The below Query just gives all the rows which matches a string
(select 1 PrioID,summary,content from CORE_DATA
where upper(CONTENT) LIKE
upper(CONCAT('%', 'Deepika Padukone is awesome' ,'%')) limit 100 )
--- A complete Match
union
(SELECT 2,summary,content FROM CORE_DATA WHERE MATCH (content)
AGAINST (replace('Deepika Padukone is awesome', ' ' , ' +')
IN BOOLEAN MODE))
--- A complete Match with ALL words present at different PLACES of the column
union
(select 3,summ,cont from
(
SELECT summary as summ,content as cont, MATCH (content)
AGAINST (replace('Deepika Padukone is awesome', ' ' , ',')
IN BOOLEAN MODE ) ---
--- A partial Match with ANY one word present at different PLACES
AS score FROM HOOTSEARCH.HOOT_DATA) q1 order by score desc limit 100)
order by PrioID
Result set:
Deepika Padukone is awesome -- Result of 1st Union clause
Deepika last name is Padukone and she really look awesome -- 2nd Union
Deepika acted in Ramleela and looking like an angel and her costumes are really nice --3rd Union
No comments:
Post a Comment