简体   繁体   English

如何在不区分大小写的索引中搜索区分大小写

[英]How to search case sensitive in a case insensitive index

I have to query with over 100 words (case insensitive) that are stored in a separate table. 我必须查询存储在单独表中的100多个单词(不区分大小写)。

Select a_id, text from xy
inner join keywords kw on contains(xy.text, kw.word)>0

This works fine. 这很好。 But now I have one keyword that has to be queried case sensitive. 但是现在我有一个必须查询的关键字,区分大小写。

Does somebody know how to do that without creating a case sensitive index and query that keyword separately? 有人知道如何做到这一点,而无需创建区分大小写的索引并单独查询该关键字吗? Is it maybe possible to ignore a keyword, let's say 'us', and only create the index with the keyword in capital letters ('US'). 也许可以忽略一个关键字(假设我们为“ us”),而仅使用该关键字以大写字母(“ US”)创建索引。

I tried it with adding 'us' to the stopwords but it didn't worked out. 我尝试在停用词中添加“ us”,但没有成功。

Add a column case_sensitive char(1) -- Y/N to the keywords table, then: keywords表中添加一列case_sensitive char(1) -- Y/N ,然后:

select a_id, text
from xy
join keywords kw on contains(xy.text, kw.word) > 0
  and (kw.case_sensitive = 'N' or instr(xy.text, kw.word) > 0)

The index will still be used, but there is an additional requirement for case sensitive keywords that the keyword must appear verbatim in the text. 该索引仍将使用,但是对于区分大小写的关键字还有一个附加要求,即关键字必须在文本中逐字出现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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