简体   繁体   中英

How to use words in text to search MySQL table?

I am creating an application in which users can save seperate notes. Within a note, the user can identify the note's keyword. If that word is mentioned in another note, I want the application to create a link to the note where the word is a keyword.

Example:

note 1: "This is a note with the [keyword]" (keywords are identified with brackets) note 2: "This is a different note, but the word keyword is mentioned"

Now I want to create a link at the word 'keyword' in note 2, that points to note 1.

When a keyword is entered, it is saved in a keyword table and linked to the corresponding note id. I don't have a good idea how to search through that keyword table when a user adds a note or existing notes are loaded. It doesn't seem to make sense to use ALL words for a SQL query, since that could create many, many queries.

What are your thoughts?

The functionality that you are asking can be implemented but the issue is intensive processing. I would suggest, first of all you should limit the maximum number of keywords for a note (say 3 or 4). Then for keyword mapping, instead of searching whole text in note 2 (ie the new note that is being added by user), first allow user to define keywords in note 2. Once keywords in note 2 are defined by user, those keywords can be compared with database keywords list upon submission and required links can be made.

Before accepting, ask user whether he wants those links to be inserted or not (Its possible that he may get 20 links but he only want to choose 3 or 4 out of those. You can also limit the number of links to be attached).

Suppose, if no match is found or user is not satisfied with links, then give option to redefine keywords and compare again.

This approach will reduce the complexity and will be easy to manage. It shall be user friendly too. Your idea has lot of space for brainstorming. May be that's not your aim, but as you ask for suggestion so I have given mine. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM