匹配查询仅在elasticsearch中返回精确值

时间:2019-05-13 06:16:49

标签: elasticsearch

我有以下文件:

    {
        "_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",
        }
    },

我正在尝试获取request_id35的结果及其置信度值。

例如如果输入仅为0.,则应同时显示两个结果。

如果输入为0.5,则只有第一个文档;如果输入为0.3,则只有第二个文档。

这是我尝试过的:

 {
  "query": { 
    "bool": { 
      "must": [ 
        { "match":  { "confidence_score": "0.33" }}
      ],
      "filter": {
        "term": {
            "request_id": "35"
        }
      }
    }
  }
}

这将提供0个结果。由于它只需要精确的值,例如0.50.3333

我认为match可以代替term使用。

如何使查询类似于LIKE中的SQL运算符?

1 个答案:

答案 0 :(得分:0)

就像我应该建议您看看弹性搜索中的<filiale filialeNr="1"> <prodGruppe val="Pflege"> <ean>0-666-4567-2-22</ean> <ean>0-777-4997-2-43</ean> <ean>0-456-4887-3-22</ean> <ean>0-55-48567-16-2</ean> </prodGruppe> <prodGruppe val="Ersatz"> <ean>1-626-7767-2-99</ean> <ean>1-256-7700-2-00</ean> <ean>1-333-7788-2-31</ean> <ean>2-446-7240-9-15</ean> <ean>9-396-7510-9-00</ean> </prodGruppe> <prodGruppe val="Audio"> <ean>7-2881-760-3-70</ean> <ean>5-2671-955-5-55</ean> <ean>1-4444-652-8-88</ean> <ean>3-1111-654-3-99</ean> </prodGruppe> <prodGruppe val="Sonstiges"> <ean>6-581-1766-3-45</ean> <ean>6-231-4777-3-15</ean> <ean>4-1161-730-3-88</ean> <ean>0-4381-880-7-00</ean> <ean>5-6661-000-0-00</ean> </prodGruppe> 类型一样,或者如果您使用的是最新版本,则可以使用ES插件编写SQL语句。

相关问题