elasticsearch - match query returns exact values only in elasticsearch
问题描述
I have following documents:
{
"_index": "testrest",
"_type": "testrest",
"_id": "sadfasdfw1",
"_score": 1,
"_source": {,
"s_item_name": "Create",
"request_id": "35",
"confidence": "0.5",
}
},
{
"_index": "testrest",
"_type": "testrest",
"_id": "asdfds",
"_score": 1,
"_source": {,
"s_item_name": "Update",
"request_id": "35",
"confidence": "0.3333",
}
},
I am trying to get results for request_id
of 35
and their confidence values.
For eg. if input is only 0.
then both results should be displayed.
And if input is 0.5
then only first doc., and if 0.3
only second doc.
Here's what I tried:
{
"query": {
"bool": {
"must": [
{ "match": { "confidence_score": "0.33" }}
],
"filter": {
"term": {
"request_id": "35"
}
}
}
}
}
This gives 0
results. Since it requires exact values only, like 0.5
or 0.3333
.
I thought match
works for this instead of term
.
How do I make the query similar to LIKE
operator in SQL
?
解决方案
就像我应该建议你看一下wildcard, prefix or match_phrase
弹性搜索中的类型,或者如果你使用的是最新版本,你可以使用 ES 插件编写 SQL 语句。
推荐阅读
- type-conversion - 如何在 cplex 中转换/获取整数表达式的值?
- reactjs - 我如何在strapi上为特定用户上传图片
- sql - 带有逗号分隔参数的 MS Query
- jenkins - 在 jenkinsfile 中使用 SSH 管道 sshCommand 时无法 cd
- javascript - Mortage Calc - 公式问题
- javascript - 为什么 fetch() 使用 ReadableStream 作为响应的主体?
- python - 索引关于其他列的数据框列和
- azure - 有没有办法在 Azure 通知中心监控推送证书的有效性和过期?
- memory - Netlogo Behaviorspace 如何保存数据,而不是基于报告者
- mysql - 为什么这个查询没有在合理的时间内完成?