将所有文本字段合并到一个可搜索字段中?

发布于 2024-09-07 14:37:31 字数 343 浏览 3 评论 0原文

人们通常会在他们的 sphinx.conf 文件中包含此查询:

sql_query = SELECT id,text_field1,text_field2,text_field3 FROM table_name

如果我将所有字段合并到一个可搜索的文本字段中,像这样,会有很大区别吗?

sql_query = SELECT id, CONCAT(text_field1,text_field2,text_field3) as searchable_text FROM table_name

一个比另一个有什么好处?

谢谢!

One would normally have this query in their sphinx.conf file :

sql_query = SELECT id,text_field1,text_field2,text_field3 FROM table_name

Would there be much difference if I combine all fields into one searchable text field like so?

sql_query = SELECT id, CONCAT(text_field1,text_field2,text_field3) as searchable_text FROM table_name

What benefits does one have over the other?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

臻嫒无言 2024-09-14 14:37:31

我认为无论哪种方式通常都很好...但是,Sphinx 能够将查询集中在某些字段(请参阅 扩展查询语法示例)。如果将所有列合并到一个字段中,您将失去这种能力。

您还将失去对某些字段的权重高于其他字段的能力。

I think either way is generally fine... however, Sphinx has the ability to focus queries at certain fields (see the extended query syntax examples). If you merge all the columns into one field, you'll lose that ability.

You'll also lose the ability to weight certain fields higher than others.

执着的年纪 2024-09-14 14:37:31

CONCAT(text_field1,text_field2,text_field3) 是错误的
使用 CONCAT(text_field1,' ',text_field2,' ',text_field3)

但最好让索引单独的字段

搜索返回相同的结果,但如果需要,您可以选择列表之一

'@text_field2 foo'

CONCAT(text_field1,text_field2,text_field3) is wrong
use CONCAT(text_field1,' ',text_field2,' ',text_field3)

but it's better to let index separate fields

search returns same result but you can select one of list if needed

'@text_field2 foo'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文