Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a78addfd
提交
a78addfd
authored
12 年前
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support drop index for Lucene full-text indices
上级
78a4f621
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
133 行增加
和
38 行删除
+133
-38
changelog.html
h2/src/docsrc/html/changelog.html
+1
-0
tutorial.html
h2/src/docsrc/html/tutorial.html
+13
-0
FullTextLucene.java
h2/src/main/org/h2/fulltext/FullTextLucene.java
+43
-12
TestFullText.java
h2/src/test/org/h2/test/db/TestFullText.java
+76
-26
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
a78addfd
...
...
@@ -49,6 +49,7 @@ Change Log
</li><li>
Improved OSGi support. H2 now registers itself as a DataSourceFactory service. Fixes issue 365.
</li><li>
Add a DISK_SPACE_USED system function. Fixes issue 270.
</li><li>
Fix a compile-time ambiguity when compiling with JDK7, thanks to a patch from Lukas Eder.
</li><li>
Supporting dropping an index for Lucene full-text indexes.
</li></ul>
<h2>
Version 1.3.170 (2012-11-30)
</h2>
...
...
This diff is collapsed.
Click to expand it.
h2/src/docsrc/html/tutorial.html
浏览文件 @
a78addfd
...
...
@@ -1215,6 +1215,12 @@ This will produce a result set that contains the query needed to retrieve the da
QUERY: "PUBLIC"."TEST" WHERE "ID"=1
</pre>
<p>
To drop an index on a table:
</p>
<pre>
CALL FT_DROP_INDEX('PUBLIC', 'TEST');
</pre>
<p>
To get the raw data, use
<code>
FT_SEARCH_DATA('Hello', 0, 0);
</code>
.
The result contains the columns
<code>
SCHEMA
</code>
(the schema name),
<code>
TABLE
</code>
(the table name),
...
...
@@ -1270,6 +1276,13 @@ This will produce a result set that contains the query needed to retrieve the da
QUERY: "PUBLIC"."TEST" WHERE "ID"=1
</pre>
<p>
To drop an index on a table:
(be warned that this will re-index all of the full-text indices for the entire database)
</p>
<pre>
CALL FTL_DROP_INDEX('PUBLIC', 'TEST');
</pre>
<p>
To get the raw data, use
<code>
FTL_SEARCH_DATA('Hello', 0, 0);
</code>
.
The result contains the columns
<code>
SCHEMA
</code>
(the schema name),
<code>
TABLE
</code>
(the table name),
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/fulltext/FullTextLucene.java
浏览文件 @
a78addfd
...
...
@@ -106,6 +106,7 @@ public class FullTextLucene extends FullText {
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS "
+
SCHEMA
+
".INDEXES(SCHEMA VARCHAR, TABLE VARCHAR, COLUMNS VARCHAR, PRIMARY KEY(SCHEMA, TABLE))"
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FTL_CREATE_INDEX FOR \""
+
FullTextLucene
.
class
.
getName
()
+
".createIndex\""
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FTL_DROP_INDEX FOR \""
+
FullTextLucene
.
class
.
getName
()
+
".dropIndex\""
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FTL_SEARCH FOR \""
+
FullTextLucene
.
class
.
getName
()
+
".search\""
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FTL_SEARCH_DATA FOR \""
+
FullTextLucene
.
class
.
getName
()
+
".searchData\""
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FTL_REINDEX FOR \""
+
FullTextLucene
.
class
.
getName
()
+
".reindex\""
);
...
...
@@ -138,6 +139,29 @@ public class FullTextLucene extends FullText {
indexExistingRows
(
conn
,
schema
,
table
);
}
/**
* Drop an existing full text index for a table. This method returns
* silently if no index for this table exists.
*
* @param conn the connection
* @param schema the schema name of the table (case sensitive)
* @param table the table name (case sensitive)
*/
public
static
void
dropIndex
(
Connection
conn
,
String
schema
,
String
table
)
throws
SQLException
{
init
(
conn
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"DELETE FROM "
+
SCHEMA
+
".INDEXES WHERE SCHEMA=? AND TABLE=?"
);
prep
.
setString
(
1
,
schema
);
prep
.
setString
(
2
,
table
);
int
rowCount
=
prep
.
executeUpdate
();
if
(
rowCount
==
0
)
{
return
;
}
reindex
(
conn
);
}
/**
* Re-creates the full text index for this database. Calling this method is
* usually not needed, as the index is kept up-to-date automatically.
...
...
@@ -233,21 +257,28 @@ public class FullTextLucene extends FullText {
* @param table the table name
*/
protected
static
void
createTrigger
(
Connection
conn
,
String
schema
,
String
table
)
throws
SQLException
{
createOrDropTrigger
(
conn
,
schema
,
table
,
true
);
}
private
static
void
createOrDropTrigger
(
Connection
conn
,
String
schema
,
String
table
,
boolean
create
)
throws
SQLException
{
Statement
stat
=
conn
.
createStatement
();
String
trigger
=
StringUtils
.
quoteIdentifier
(
schema
)
+
"."
+
StringUtils
.
quoteIdentifier
(
TRIGGER_PREFIX
+
table
);
stat
.
execute
(
"DROP TRIGGER IF EXISTS "
+
trigger
);
StringBuilder
buff
=
new
StringBuilder
(
"CREATE TRIGGER IF NOT EXISTS "
);
// the trigger is also called on rollback because transaction rollback
// will not undo the changes in the Lucene index
buff
.
append
(
trigger
).
append
(
" AFTER INSERT, UPDATE, DELETE, ROLLBACK ON "
).
append
(
StringUtils
.
quoteIdentifier
(
schema
)).
append
(
'.'
).
append
(
StringUtils
.
quoteIdentifier
(
table
)).
append
(
" FOR EACH ROW CALL \""
).
append
(
FullTextLucene
.
FullTextTrigger
.
class
.
getName
()).
append
(
'\"'
);
stat
.
execute
(
buff
.
toString
());
if
(
create
)
{
StringBuilder
buff
=
new
StringBuilder
(
"CREATE TRIGGER IF NOT EXISTS "
);
// the trigger is also called on rollback because transaction rollback
// will not undo the changes in the Lucene index
buff
.
append
(
trigger
).
append
(
" AFTER INSERT, UPDATE, DELETE, ROLLBACK ON "
).
append
(
StringUtils
.
quoteIdentifier
(
schema
)).
append
(
'.'
).
append
(
StringUtils
.
quoteIdentifier
(
table
)).
append
(
" FOR EACH ROW CALL \""
).
append
(
FullTextLucene
.
FullTextTrigger
.
class
.
getName
()).
append
(
'\"'
);
stat
.
execute
(
buff
.
toString
());
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestFullText.java
浏览文件 @
a78addfd
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论