将所有文本字段合并到一个可搜索字段中?
人们通常会在他们的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为无论哪种方式通常都很好...但是,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.
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'