我想将 select body fromarticles
结果集而不是 database
作为 AGAINST
参数列表中的关键字传递。我怎样才能做到这一点?我想根据表中匹配的关键字找到相关文章。
SELECT * FROM articles
WHERE MATCH (title,body)
AGAINST ('database' IN NATURAL LANGUAGE MODE);
我想这样做:
SELECT * FROM articles
WHERE MATCH (title,body)
AGAINST ("select title,body from articles" IN NATURAL LANGUAGE MODE);
编辑 评论:
我想根据文章频道中匹配关键词的密度来获取相关文章。我已经创建了 FULLTEXT
索引,并且我的表采用 ISAM 格式。目前文章频道包含字幕和正文自定义字段。由于一切都必须是动态的,所以我无法在 AGAINST('Lorem Manager')
中传递关键字,因为我们不知道当我们访问下一篇新闻文章时关键字是什么,所以我嵌入select 语句来提取标题和正文。我得到了结果,但不知何故我的停止关键字不被识别。
I would like to pass select body from articles
result-set instead of database
as a keyword inside the AGAINST
parameter list. How can I do that?. I want to find the related articles based on the matching keywords from the table.
SELECT * FROM articles
WHERE MATCH (title,body)
AGAINST ('database' IN NATURAL LANGUAGE MODE);
I want do to this:
SELECT * FROM articles
WHERE MATCH (title,body)
AGAINST ("select title,body from articles" IN NATURAL LANGUAGE MODE);
Edit from comment:
I would like to get the related article based on the density of the matching keywords in the article channel. I have created the FULLTEXT
index and my table is in ISAM format. Currently the article channel contains subtitle and body custom fields. Since everything has to be dynamic so I cannot pass the keywords inside the AGAINST('Lorem Manager')
because we don't know what will be the keywords when we visit the next news article, so I embed select statement to pull the title and body. I am getting result but somehow my stop keywords are not recognized.
发布评论
评论(1)
您到底希望实现什么目标?
为了更好地理解(并可能说明)您所要求的内容,让我们用 ExpressionEngine 的用语来讨论,毕竟这就是您标记问题的内容。
使用 Agile Records ExpressionEngine 站点主题,让我们使用“关于”通道中的两个字段 — 正文和员工职务:
首先,如果您还没有这样做,您需要 创建一个 FULLTEXT 索引,其中包含您正在搜索的所有列。
使用上面的两列,从 phpMyAdmin 或您最喜欢的 MySQL GUI 客户端执行以下 SQL 语句:
您可以使用以下查询验证新创建的 INDEX:
要针对文本集合 ( ) 对字符串(关键字)执行自然语言搜索一个或多个数据库列),请考虑以下内容...其中 Lorem 和 Manager 是您的关键字:
这将返回如下结果集(为了便于阅读而进行了简化):
使用自然语言全文时搜索时,要求 MATCH() 函数中指定的列与表中某些 FULLTEXT 索引中包含的列相同。
例如,在前面的示例中,请注意 MATCH() 函数中命名的列(field_id_4 和 field_id_6)与文章表定义中命名的列相同全文索引。
如果您想单独搜索列,则需要为每列创建单独的 FULLTEXT 索引。
全文搜索中会忽略某些单词:
默认停用词列表可以在 11.9.4 中查看。 MySQL 文档的全文停用词。
What are you hoping to achieve, exactly?
To better understand — and perhaps illustrate — what you're asking for, let's discuss things in ExpressionEngine parlance, after all that's what you tagged your question with.
Using the Agile Records ExpressionEngine site theme, let's use two fields from the About channel — Body and Staff Member's Title:
First, if you haven't already, you need to create a single FULLTEXT index that contains all of the columns you're searching on.
Using the two columns from above, execute the following SQL statement from phpMyAdmin or your favorite MySQL GUI Client:
You can verify the newly created INDEX with the following query:
To perform a natural language search for a string (keywords) against a text collection (one or more database columns), consider the following ... where Lorem and Manager are your keywords:
Which would return a result set like the following (simplified for readability):
When using natural-language full-text searches, it is a requirement that the columns named in the MATCH() function be the same columns included in some FULLTEXT index in your table.
For instance, in the preceding example note that the columns named in the MATCH() function (field_id_4 and field_id_6) are the same as those named in the definition of the article table's FULLTEXT index.
If you wanted to search the columns separately, you would need to create separate FULLTEXT indexes for each column.
Some words are ignored in full-text searches:
The default stop word list can be viewed in 11.9.4. Full-Text Stopwords of the MySQL Documentation.