Fulltext show the matching word in a multi-word search condition with OR

大兔子大兔子 提交于 2021-01-28 18:54:16

问题


I have a full-text indexed table and a column that is full-text indexed which contains a list of ids and some other information.

Example:

SearchInformation
100, 101, 102, 103, 104, Mike
200, 201, 202, 203, 204, John

And my full-text query (a simplified version) is:

SELECT searchInformation
FROM Table T1
    INNER JOIN CONTAINSTABLE(SearchTable, SearchInformation, '"100" OR "110" OR "Mick"') k
        ON T1.ID = k.[key]

Now, this query identifies the correct row due to the "100" value being matched, but is there any way to show / select which value has been matched from my search conditions?

In this case, I also want to select the value of 100 from my query. I have looked into the Full-text documentation and I'm not sure if this is possible or if it is with maybe some additional changes in table and query design.

So, I'm looking for a result set similar to:

SearchInformation                    matchFound
100, 101, 102, 103, 104, Mike        100

I currently have an approach where each ID number is associated with Mike or John in a single row, like below, so then, after the match I can directly take the matched value from the ID column.

SearchInformation    ID
100, Mike            100
101, Mike            101
102, Mike            102
103, Mike            103
200, John            200
201, John            201

But I would like to change this to use the previously mentioned design, if possible. I know that the previous approach is terribly non-relational, but I'm curious if it's possible.

来源:https://stackoverflow.com/questions/40484312/fulltext-show-the-matching-word-in-a-multi-word-search-condition-with-or

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!