创建要添加到搜索索引的文档时,可以指定文档语言。我已经完成了这项工作,但现在只想查询特定语言的文档。这可能吗?我认为这将是微不足道的(并记录在案),但我找不到如何做到这一点。
谢谢!
答案 0 :(得分:2)
我认为你现在不能,但我没有看到任何明确的说法。我从这些句子中暗示语言字段是供它们使用而不是用于查询。
search.TextField的语言参数:
Two-letter ISO 693-1 language code for the field's content, to assist in tokenization. If None, the language code of the document will be used.
Search supports all space-delimited languages as well as some languages not segmented by spaces (specifically, Chinese, Japanese, Korean, and Thai). For these languages, Search segments the text automatically.
他们需要了解语言,以便他们知道如何将其解析为单词。
我的计划是在我的搜索文档中添加一个与语言字段具有相同值的附加字段。这有点多余,但很容易做到。
search.Document(
fields = [
...,
search.TextField(name='language', value=lang),
],
language = lang,
)