【发布时间】:2020-06-29 22:31:48
【问题描述】:
我使用 7.6.1 版本的 Elasticsearch,我尝试索引简单对象并查询它们。 我的索引没有问题,我可以按 id 查询,但是当我尝试将搜索与 Term 查询一起使用时,它会失败(0 Hit)。我不明白我做错了什么。
PUT product/_doc/b0264dad-6739-49ea-b691-e05a2883a724
{
"name": "Name 2",
"description": "Desc 1",
"price": 11,
"startSell": "2020-06-28T12:24:37.0070067+00:00",
"endSell": "2020-07-19T12:24:37.0070161+00:00",
"variants": [
{
"color": "Red",
"size": 1
},
{
"color": "Red",
"size": 1
},
{
"color": "Red",
"size": 1
},
{
"color": "Blue",
"size": 1
},
{
"color": "Yellow",
"size": 1
},
{
"color": "Yellow",
"size": 2
},
{
"color": "Yellow",
"size": 3
},
{
"color": "Purple",
"size": 4
}
]
}
有效,我可以通过它的 id 获取对象:
GET product/_doc/b0264dad-6739-49ea-b691-e05a2883a724
返回
{
"_index" : "product",
"_type" : "_doc",
"_id" : "b0264dad-6739-49ea-b691-e05a2883a724",
"_version" : 1,
"_seq_no" : 6,
"_primary_term" : 1,
"found" : true,
"_source" : {
"name" : "Name 2",
"description" : "Desc 1",
"price" : 11,
"startSell" : "2020-06-28T12:24:37.0070067+00:00",
"endSell" : "2020-07-19T12:24:37.0070161+00:00",
"variants" : [
{
"color" : "Red",
"size" : 1
},
{
"color" : "Red",
"size" : 1
},
{
"color" : "Red",
"size" : 1
},
{
"color" : "Blue",
"size" : 1
},
{
"color" : "Yellow",
"size" : 1
},
{
"color" : "Yellow",
"size" : 2
},
{
"color" : "Yellow",
"size" : 3
},
{
"color" : "Purple",
"size" : 4
}
]
}
}
但是这三个请求都返回没有数据,我做错了什么? :
POST product/_search
{
"query": {
"bool": {
"filter": [
{
"terms": {
"name": [
"Name 2"
]
}
}
]
}
}
}
POST product/_search
{
"query": {
"term": {
"name": {
"value": "Name 2",
"boost": 1
}
}
}
}
POST product/_search
{
"query": {
"term": {
"description": {
"value": "Desc 1",
"boost": 1
}
}
}
}
【问题讨论】:
-
你能提供你的索引的映射吗?
-
我如何在 Kibana 中找到这个?
标签: elasticsearch search