在某些情况下,Sphinx 返回的结果没有我声明为 sql_attr_string 的 JOIN 字段。以以下源/索引配置为例:
source myapp_recipe
{
type = pgsql
sql_host =
sql_user = me
sql_pass = secret
sql_db = myapp_db
sql_port =
sql_query = \
SELECT myapp_recipe.id as id, \
myapp_recipe.name as name, \
myapp_recipe.cookbook_id as cookbook_id, \
myapp_cookbook.name as cookbook_name, \
'recipe' as content_type \
FROM myapp_recipe \
INNER JOIN myapp_cookbook \
ON myapp_recipe.cookbook_id = myapp_cookbook.id
#content_type for django
sql_attr_string = content_type
# stored string fields in the document
sql_attr_string = cookbook_name
# stored and indexed string fields
sql_field_string = name
# ForeignKey's
sql_attr_uint = cookbook_id
}
index myapp_recipe
{
source = myapp_recipe
path = /var/data/myapp_recipe
docinfo = extern
morphology = none
stopwords =
min_word_len = 2
charset_type = utf-8
min_prefix_len = 0
min_infix_len = 3
enable_star = 0
}
对于某些搜索,返回的结果文档除了content_type
和之外没有其他属性name
。对于返回相同文档的不同搜索,Sphinx 很可能返回具有所有预期属性的相同结果文档。
示例:“pizza”查询将返回不完整的结果文档 (documentA),没有 JOIN 字符串属性。
对“pizza pocket”的查询将返回具有所有预期 JOIN 属性的相同文档 (documentA)。
谁能解释这种莫名其妙的行为?