ElasticSearch:是否有任何选项可以通过简单地在 ElasticSearch 中提供查询来搜索文档中的所有字段
ElasticSearch: is there any option to search in all fileds in document by simply giving the query in ElasticSearch
我是 Elasticserach 的新手,正在为我们现有的场景寻找解决方案。假设我创建了一个文档:
{
"employee": {
"properties": {
"id" : {"type": "string"},
"value": {"type": "string"},
"role": {"type": "string"},
"desc": {"type": "string"}
}
}
}
而且我想在不明确指定字段名称的情况下搜索字段。
例如,如果我的搜索查询字符串是 "Bin",我想在所有字段 id、value、role 和 desc 中进行搜索。 ElasticSearch有什么办法吗?
您可以使用 _all 字段来完成。它允许您在不指定字段名称的情况下搜索文档。
但是请仔细阅读文档,因为:
This comes at the expense of CPU cycles and index size.
我是 Elasticserach 的新手,正在为我们现有的场景寻找解决方案。假设我创建了一个文档:
{
"employee": {
"properties": {
"id" : {"type": "string"},
"value": {"type": "string"},
"role": {"type": "string"},
"desc": {"type": "string"}
}
}
}
而且我想在不明确指定字段名称的情况下搜索字段。
例如,如果我的搜索查询字符串是 "Bin",我想在所有字段 id、value、role 和 desc 中进行搜索。 ElasticSearch有什么办法吗?
您可以使用 _all 字段来完成。它允许您在不指定字段名称的情况下搜索文档。
但是请仔细阅读文档,因为:
This comes at the expense of CPU cycles and index size.