用于Elasticsearch的设计查询:
我的mysql数据库中有10个表:新闻,电子邮件等。我将这些表同步到elasticsearch中。我想一次搜索所有这些表。
表中没有关系,所有表中都有txt
字段。只想在txt
字段中搜索..所以我应该有多个索引还是只有1个索引。
我应该如何组织索引:
选项1:我是否应该对所有表仅使用一个Elasticsearch索引(具有表类型的属性)
要么
选项2:我是否应该对所有表都使用多个Elasticsearch索引
考虑:
最佳答案
具有多个索引,并在任何给定时间查询任意多个索引:
POST emails/_doc
{
"txt": "abc"
}
POST news/_doc
{
"txt": "ab"
}
GET emails,news/_search
{
"query": {
"query_string": {
"default_field": "txt",
"query": "ab OR abc"
}
}
}
万一通配符索引名称也为supported,以防万一,例如带有时间戳记的名称,例如
emails_2020
,emails_2019
等:GET em*,ne*/_search
...
关于elasticsearch - 多索引 Elasticsearch 全文本搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61715652/