Hashtable使用哈希?(Hashing used by Hashtable?)
Java中的
Hashtable
实现使用了什么样的哈希方法?What kind of hashing methodoly is used in
Hashtable
implementation in Java?
原文:https://stackoverflow.com/questions/4546287
最满意答案
您需要先根据您的查询创建一个
VIEW
,然后为其添加一个全文索引,其中将包含ParentName
列。 如果没有正在搜索的列上的全文索引,FREETEXT
和CONTAINS
都不起作用。像这样的东西应该可以帮助你:
CREATE VIEW ExpectationsView AS SELECT ExpectationId ,ExpectationName ,( CASE WHEN ExpectationOrganization_OrganizationId IS NOT NULL THEN ( SELECT OrganizationName FROM Organizations WHERE OrganizationId = ExpectationOrganization_OrganizationId ) WHEN ExpectationBeneficiary_BeneficiaryId IS NOT NULL THEN ( SELECT BeneficiaryName FROM Beneficiaries WHERE BeneficiaryId = ExpectationBeneficiary_BeneficiaryId ) ELSE ( SELECT TeamName FROM Teams WHERE TeamId = ExpectationTeam_TeamId ) END ) AS ParentName FROM Expectations GO -- This index is needed for FTS index. -- Note, I trust ExpectationId column is unique in your SELECT above, -- if it's not, the below CREATE INDEX will fail and you will need to provide -- a new column to your VIEW which will uniquely identify each row, then use -- that PK-like column in the below index CREATE UNIQUE CLUSTERED INDEX PK_ExpectationsView ON ExpectationsView (ExpectationId); GO CREATE FULLTEXT CATALOG fts_catalog; GO CREATE FULLTEXT INDEX ON ExpectationsView ( ExpectationName Language 1033, ParentName Language 1033 ) KEY INDEX PK_ExpectationsView ON fts_catalog; WITH (CHANGE_TRACKING = AUTO) GO
一旦包含相关列的全文索引存在,您可以在查询中使用
FREETEXT
或CONTAINS
:SELECT ExpectationId, ExpectationName, ParentName FROM ExpectationsView WHERE FREETEXT(ExpectationName, @Keyword) OR FREETEXT(ParentName, @Keyword)
请注意,上面提供的代码是我的头顶,因为我没有数据模式,因此无法尝试运行它。 但是,它应该给你关于如何进行的一般想法。 HTH。
You need to create a
VIEW
based on your query first then add a Full-Text index to it which will include theParentName
column. Without the Full-Text index over a column being searched neitherFREETEXT
norCONTAINS
will work.Something like that should help you:
CREATE VIEW ExpectationsView AS SELECT ExpectationId ,ExpectationName ,( CASE WHEN ExpectationOrganization_OrganizationId IS NOT NULL THEN ( SELECT OrganizationName FROM Organizations WHERE OrganizationId = ExpectationOrganization_OrganizationId ) WHEN ExpectationBeneficiary_BeneficiaryId IS NOT NULL THEN ( SELECT BeneficiaryName FROM Beneficiaries WHERE BeneficiaryId = ExpectationBeneficiary_BeneficiaryId ) ELSE ( SELECT TeamName FROM Teams WHERE TeamId = ExpectationTeam_TeamId ) END ) AS ParentName FROM Expectations GO -- This index is needed for FTS index. -- Note, I trust ExpectationId column is unique in your SELECT above, -- if it's not, the below CREATE INDEX will fail and you will need to provide -- a new column to your VIEW which will uniquely identify each row, then use -- that PK-like column in the below index CREATE UNIQUE CLUSTERED INDEX PK_ExpectationsView ON ExpectationsView (ExpectationId); GO CREATE FULLTEXT CATALOG fts_catalog; GO CREATE FULLTEXT INDEX ON ExpectationsView ( ExpectationName Language 1033, ParentName Language 1033 ) KEY INDEX PK_ExpectationsView ON fts_catalog; WITH (CHANGE_TRACKING = AUTO) GO
Once the Full-Text index which includes the relevant columns is there you can use
FREETEXT
orCONTAINS
in queries:SELECT ExpectationId, ExpectationName, ParentName FROM ExpectationsView WHERE FREETEXT(ExpectationName, @Keyword) OR FREETEXT(ParentName, @Keyword)
Note, the above code I've provided off the top of my head because I don't have data schema for your case so couldn't try running it. However, it should give you the general idea on how to proceed. HTH.
相关问答
更多-
SQL Server全文搜索中的Contains子句省略了一些匹配的行(Contains clause in SQL Server full-text search omits some matching rows)[2023-03-10]
这是由于全文搜索的工作方式,它与工作方式不同,因为它不是简单的模式匹配,它是语言识别的,实际上是在寻找单词,因此它为什么找到带有“单词”i2的行它,但不是具有“word”id21的那个(id 352)。 如果要使用全文搜索,可以执行的是执行前缀搜索,您可以在其中搜索以i2开头的单词,如下所示: SELECT p.ProductId, p.ProductName FROM Products p WHERE contains(p.ProductName, N'"i2*"'); 请注意,您不能在N'"*i2*" ... -
我可以建议一下: SELECT *, CASE WHEN CONTAINS(CompanyName, 'Salv') THEN 'CompanyName' WHEN CONTAINS(Street, 'Salv') THEN 'Street' WHEN CONTAINS(City, 'Salv') THEN 'City' END As ColumnName, CASE WHEN CONTAINS(CompanyN ...
-
SQL Server 2005全文搜索多个表和列(SQL Server 2005 Full Text Search over multiple tables and columns)[2022-06-08]
我有同样的问题。 这是我的解决方案,它适用于我的情况: 我创建了一个返回我想要的列的视图。 我添加了另一个额外的列,它汇总了我想要搜索的所有列。 所以,在这种情况下,视图会是这样的 SELECT emp.*, addr.*, ISNULL(emp.Name,'') + ' ' + ISNULL(addr.City, '') AS SearchResult FROM Employee emp LEFT OUTER JOIN [Address] addr ON addr.EmployeeId = e ... -
SQL Server +全文搜索+ Unicode和不同的结果集(SQL Server + Full-Text Search + Unicode and different result sets)[2023-04-02]
全文重音敏感度是全文目录的属性。 您可以在目录创建期间设置灵敏度: CREATE FULLTEXT CATALOG ... ACCENT_SENSITITY = OFF 或事后修改: ALTER FULLTEXT CATALOG [my_fulltext_catalog] REBUILD WITH ACCENT_SENSITIVITY = OFF Full-Text accent sensitivity is a property of the Full-Text catalog. You can set ... -
请参阅有关mysql中全文搜索支持的文档: http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html 您需要将全文索引应用于列,以支持在这些列上进行全文搜索。 请注意,mysql仅支持MyISAM表上的全文索引。 作为一个例子,以防万一上面的链接在某些时候死了,从文档中看到一个完整的例子: mysql> CREATE TABLE articles ( -> id INT UNSIGNED AUTO_INCREMENT NOT NULL ...
-
您需要先根据您的查询创建一个VIEW ,然后为其添加一个全文索引,其中将包含ParentName列。 如果没有正在搜索的列上的全文索引, FREETEXT和CONTAINS都不起作用。 像这样的东西应该可以帮助你: CREATE VIEW ExpectationsView AS SELECT ExpectationId ,ExpectationName ,( CASE WHEN ExpectationOrganization_OrganizationId ...
-
SELECT * FROM workspace WHERE CONTAINS(WorkspaceName, '"red*" OR "blue*"') SELECT * FROM workspace WHERE CONTAINS(WorkspaceName, '"red*" OR "blue*"')
-
您可以在下面提到的URL中找到有关全文搜索的更多信息。 http://blog.sqlauthority.com/2008/09/05/sql-server-creating-full-text-catalog-and-index/ http://blog.sqlauthority.com/2009/12/26/sql-server-whitepaper-sql-server-2008-full-text-search-internals-and-enhancements/ You can find mor ...
-
全文将根据您提供的搜索条件进行操作。 您可以从文件中删除干扰词,但实际上这样做可能会使索引大小膨胀。 Robert Cain在他的博客上有很多关于此的信息: http://arcanecode.com/2008/05/29/creating-and-customizing-noise-words-in-sql-server-2005-full-text-search/ 为了节省一些时间,您可以查看此方法如何删除它们并复制代码和单词: public string PrepSearchStrin ...
-
SQL Server 2008支持这些词汇应该可以帮助您到达所需的位置。 您可以将拼写错误定义为同义词。 请参阅http://msdn.microsoft.com/en-us/library/ms142491.aspx 。 编辑:根据我的理解,你不能使用通配符或正则表达式方法。 您必须为您预期最常被误输入的单词定义常见的替换集模式。 SQL Server 2008 supports thesauruses should get you to where you need. You would define ...