1

How do you add a column to a fulltext search in MySQL to indicate which words were included in the search?

3 Answers 3

2

You mean query or index definition? For query it would be something like this:

WHERE 
  MATCH (colA, colB) AGAINST ('+words* +you* +search*' IN BOOLEAN MODE)
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your help. The SELECT statement is really where I need the guidance. For example, if this is the query: select AlbumID, Title from Albums where match(AlbumDesc) against('albums') union select AlbumID, Title from Albums where match(AlbumDesc) against('albums' with query expansion) union select AlbumID, Title from Albums where match(AlbumDesc) against('studio') union select AlbumID, Title from Albums where match(AlbumDesc) against('studio' with query expansion); how do I display the words used for the query (i.e. 'album' and 'studio')?
If you want to know, which word does the result fit, then you can always add this word to the result, ie: select AlbumID, Title, 'albums' as SearchWord from Albums where match(AlbumDesc) against('albums') and do the same with other queries.
2

Michal got the query syntax down, to create a full text index to assist this search use

Create FULLTEXT Index Test ON Table1(ColumnName1)

Much more at MySQL Docs

Comments

-3

Use the following command

ALTER TABLE "table_name"
ADD INDEX " INDEX_NAME " (COLUMN_NAME)

1 Comment

-1 I think this is only useful for a standard search not the full-text search the questioner desires (i.e. search for any word or words within the field)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.