我有一些客户具有用户正在搜索的特定地址:
123通用方式
数据库中有5行匹配:
ResidentialAddress1
=============================
123 GENERIC WAY
123 GENERIC WAY
123 GENERIC WAY
123 GENERIC WAY
123 GENERIC WAY
Run Code Online (Sandbox Code Playgroud)
我运行FT查询来查找这些行.我将向您展示每一步,因为我为搜索添加了更多条件:
SELECT ResidentialAddress1 FROM Patrons
WHERE CONTAINS(Patrons.ResidentialAddress1, '"123*"')
ResidentialAddress1
=========================
123 MAPLE STREET
12345 TEST
123 MINE STREET
123 GENERIC WAY
123 FAKE STREET
...
(30 row(s) affected)
Run Code Online (Sandbox Code Playgroud)
好的,到目前为止一直很好,现在添加" 通用 " 一词:
SELECT ResidentialAddress1 FROM Patrons
WHERE CONTAINS(Patrons.ResidentialAddress1, '"123*"')
AND CONTAINS(Patrons.ResidentialAddress1, '"generic*"')
ResidentialAddress1
=============================
123 GENERIC WAY
123 GENERIC WAY
123 GENERIC WAY
123 GENERIC WAY
123 GENERIC WAY
(5 …Run Code Online (Sandbox Code Playgroud) sql-server full-text-search sql-server-2000 full-text-indexing
我想在Lucene中找到一些经常出现的短语.我从TXT文件中获取一些信息,并且因为没有短语信息而丢失了很多上下文,例如"信息检索"被索引为两个单独的单词.
获取这样的短语的方法是什么?我在互联网上找不到任何有用的东西,所有的建议,链接,提示特别是例子表示赞赏!
编辑:我只是按标题和内容存储我的文件:
Document doc = new Document();
doc.add(new Field("name", f.getName(), Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("text", fReader, Field.TermVector.WITH_POSITIONS_OFFSETS));
Run Code Online (Sandbox Code Playgroud)
因为我正在做的事情,最重要的是文件的内容.标题往往不具有描述性(例如,我有许多PDF学术论文,其标题是代码或数字).
我迫切需要从文本内容中索引最常出现的短语,刚才我看到这个简单的"词袋"方法效率不高.
我正在用巴西葡萄牙语开发一个简单的文章网站.搜索功能基于全文搜索,但未返回预期结果.
我在postgresql上做了这个.这是简化表:
Artigos
-id
-title -- article title
-intro -- article introduction
-content -- article body
-publishdate -- date of launch
-artigosts -- this will work as our fts index.
Run Code Online (Sandbox Code Playgroud)
创建表后,我跑了:
UPDATE artigos SET artigosts =
setweight(to_tsvector('pg_catalog.portuguese', coalesce(title,'')), 'A') ||
setweight(to_tsvector('pg_catalog.portuguese', coalesce(intro,'')), 'B') ||
setweight(to_tsvector('pg_catalog.portuguese', coalesce(content,'')), 'C');
CREATE INDEX artigosts_idx ON artigos USING gist (artigosts);
CREATE TRIGGER artigosts_tg
BEFORE INSERT OR UPDATE ON artigos
FOR EACH ROW EXECUTE PROCEDURE
tsvector_update_trigger('artigosts', 'pg_catalog.portuguese', 'title', 'intro', 'content');
Run Code Online (Sandbox Code Playgroud)
是的,我打算在搜索中使用简单的加权.做了一个索引加速,一个触发器,所以我可以插入和更新,而无需担心重制索引等.
嗯,根据我的理解,一切都很好.但结果不是.一个简单的例子.
假设我有"...... banco de …
postgresql full-text-search internationalization full-text-indexing
我有一个SQL Server 2008数据库,其全文索引设置为一个用于搜索的表列.
当尝试使用带有以下条件的CONTAINS子句对表执行查询时:"003",它忽略前导零并返回匹配"3"的所有行.
我们正在尝试考虑搜索的前导零,任何想法?
(全文的停止列表为空).
更新:查询
SELECT * FROM Table
WHERE CONTAINS(SearchIndex, '"003*"')
Run Code Online (Sandbox Code Playgroud) sql-server full-text-search full-text-indexing sql-server-2008
假设我有一个"文章"表,其中包含以下列:
article_text: fulltext indexed
author_id: indexed
Run Code Online (Sandbox Code Playgroud)
现在我想搜索一篇特定蒿动作文章中出现的术语.
像这样的东西:
select * from articles
where author_id=54
and match (article_text) against ('foo');
Run Code Online (Sandbox Code Playgroud)
这个查询的解释告诉我mysql只会使用全文索引.我相信mysql只能使用1个索引,但是在全文搜索术语之前,确定一个特定作者首先编写的所有文章似乎是一个明智的想法...所以无论如何都要帮助mysql?
例如..如果你做了自我加入?
select articles.* from articles as acopy
join articles on acopy.author_id = articles.author_id
where
articles.author_id = 54
and match(article_text) against ('foo');
Run Code Online (Sandbox Code Playgroud)
对此的解释首先列出了author_id索引的使用,然后是全文搜索.
这是否意味着它实际上只在有限集上进行全文搜索,由author_id过滤?
附录
解释自我加入的计划如下:
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: acopy
type: ref
possible_keys: index_articles_on_author_id
key: index_articles_on_author_id
key_len: 5
ref: const
rows: 20
filtered: 100.00
Extra: Using where; Using index
*************************** 2. row ***************************
id: 1 …Run Code Online (Sandbox Code Playgroud) 我正在经历管理工作室GO的一个非常奇怪的行为.
我正在关注全文搜索教程,并在冒险工作中运行以下查询
SELECT FT_TBL.ProductDescriptionID,
FT_TBL.Description,
KEY_TBL.RANK
FROM Production.ProductDescription AS FT_TBL INNER JOIN
CONTAINSTABLE (Production.ProductDescription,
Description,
'(light NEAR aluminum) OR
(lightweight NEAR aluminum)'
) AS KEY_TBL
ON FT_TBL.ProductDescriptionID = KEY_TBL.[KEY]
WHERE KEY_TBL.RANK > 2
ORDER BY KEY_TBL.RANK DESC;
Run Code Online (Sandbox Code Playgroud)
当我使用Go(在查询之前)和没有Go运行它时,结果是不同的.我玩了一些 - 复制了选择并添加了介于两者之间,结果仍然不同.从图片中注意,它是相同的选择,写入两次,但有两个不同的结果

任何的想法?
编辑:
刚刚发现执行计划因为去了
------ LINK ----------

sql-server full-text-search full-text-indexing sql-server-2012
我们最近将我们的数据库升级到Oracle 12c,从那时起它ORA-44003: invalid sql name在插入具有cat索引的表时抛出异常.
我们在一列上只有cat索引,这对Oracle 11g运行良好.
有趣的是,如果我继续尝试,我可以插入相同的记录.有时在第二次,有时在第十次尝试.
这是一个例外:
Internal Exception: java.sql.SQLException: ORA-44003: invalid SQL name
ORA-06512: at "SYS.DBMS_ASSERT", line 479
ORA-06512: at "CTXSYS.DRVDML", line 415
ORA-06512: at "EMISDB.DR$IDX_AML_NOTICE_DESCTC", line 1
ORA-04088: error during execution of trigger 'SONARDB.DR$IDX_NOTICE_DESCTC'
Run Code Online (Sandbox Code Playgroud)
我删除并使用脚本创建了cat索引:
create index IDX_NOTICE_DESC on NOTICE (DESCRIPTION) indextype is ctxsys.ctxcat
Run Code Online (Sandbox Code Playgroud)
我会很感激任何提示.
ALTER TABLE TableName
ADD FULLTEXT INDEX IndexName(ColumnName);
这是在mysql中添加全文索引的查询.
但是,我想要添加全文索引的laravel查询.
提前致谢......
我想在 MongoDB 中创建一个文本索引,它允许用户搜索字符串元素数组的字段。
例如,我的文档看起来像
{
"stringfield": "hello",
"arrayfield": ["one", "two", "three"]
}
Run Code Online (Sandbox Code Playgroud)
我希望搜索“two”的用户能够找到此文档。用户无权直接访问数据库。目前,pymongo 通过以下方式执行查询
our_mongo.find({'$text':{'$search': user_input }}, {'score':{'$meta':"textScore"}})
Run Code Online (Sandbox Code Playgroud)
根据 mongo文档,
“文本索引可以包含值为字符串或字符串元素数组的任何字段。”
虽然成功搜索了字符串值,但我无法获取文本索引来处理字符串元素数组。我的索引是使用以下命令创建的:
db.mydocs.createIndex(
{
'_id': 'text',
'stringfield': 'text', // works
'arrayfield': 'text', // does NOT work --> EDIT: DOES work
},
{
weights: {
'stringfield': 10,
'arrayfield': 5
},
name: 'search'
}
);
Run Code Online (Sandbox Code Playgroud) 对于特定的全文搜索,我需要修改标准停用词文件并排除一些单词。到目前为止我做了什么:
复制german.stop到german_modified.stop,然后从 中删除文字german_modified.stop。然后:
CREATE TEXT SEARCH DICTIONARY public.german_nostop (
TEMPLATE = pg_catalog.simple,
STOPWORDS = german_modified
);
CREATE TEXT SEARCH CONFIGURATION public.german_nostop (
COPY = pg_catalog.german
);
ALTER TEXT SEARCH CONFIGURATION public.german_nostop
ALTER MAPPING
FOR asciiword, asciihword, hword_asciipart, hword, hword_part, word
WITH german_nostop;
CREATE INDEX body_idx ON comments
USING gin (to_tsvector('german_nostop', body));
Run Code Online (Sandbox Code Playgroud)
但当我这样做时
SELECT body, autor
FROM comments
WHERE to_tsvector('german_nostop', body) @@ to_tsquery('wie');
Run Code Online (Sandbox Code Playgroud)
我得到:
NOTICE: text-search query contains only stop words or doesn't contain lexemes, …Run Code Online (Sandbox Code Playgroud)