在Elasticsearch中实现标签搜索的最佳方法是什么?
到目前为止,我的工作情况如下。
我的文档:
{
"_index": "phaasddb",
"_type": "phaasddb_type",
"_id": "id=Container-Image-c234a762-6848-4746-bd39-ab1ec4107e44|pk=Container",
"_score": 0.5753642,
"_source": {
"kind": "Image",
"name": "DJI_00020356.jpg 27",
"tags": [
"RekLabel-Spruce",
"RekLabel-Nature",
"RekLabel-Scenery",
"RekLabel-Flora",
"RekLabel-Aerial View",
"RekLabel-Outdoors",
"RekLabel-Tree",
"RekLabel-Landscape",
"RekLabel-Conifer",
"RekLabel-Plant"
],
"description": "Description",
"@SequenceNumber": "72247500000000054697124676",
"location": "Austin",
"@timestamp": "2018-09-19T22:18:21.915073",
"pk": "Container",
"id": "Container-Image-c234a762-6848-4746-bd39-ab1ec4107e44",
"createdAt": 1536877933
}
}
和我的查询:
GET _search
{
"query": {
"bool": {
"must": [
{ "match": { "tags": "Spruce" }},
{ "match": { "tags": "Scenery" }}
]
}
}
}
“标签”字段只是一个字符串,我正在将一个数组转储到其中。我读到有关嵌套“标签”并可能使用“条款”查询的信息。这很重要吗?我不太了解,到目前为止,这似乎行得通。