简体   繁体   English

弹性搜索以一半的值检索结果

[英]Elastic search retrieving results with half the value

I am trying to check whether client_id is already exists in the index or not.我正在尝试检查 client_id 是否已存在于索引中。 but problem is ES still retrieving full ID, even though I am giving half of the id.但问题是 ES 仍然检索完整的 ID,即使我给出了一半的 ID。 here is the mapping.这是映射。

'mappings': {
            'properties': {
                'client_id': {'index': 'true','type': 'keyword'},
                'client_name': {'index': 'true', 'type': 'keyword'},
                'data_index_server': {'type': 'ip'},
                'data_file_node_path': {'index': 'true', 'type': 'keyword'},
            }

If I have the record like this如果我有这样的记录

{
  "_index": "client_index",
  "_type": "_doc",
  "_id": "wYlkrYMB_q_jkYaCv6pU",
  "_version": 1,
  "_score": 1,
  "_source": {
    "doc": {
      "client_id": "0935be6b-61fe-4ec4-80c8-5c5ee8384378",
      "client_name": "citi",
      "data_file_node_path": " ",
      "data_index_server": " "
    }
  },
  "fields": {
    "doc.client_id": [
      "0935be6b-61fe-4ec4-80c8-5c5ee8384378"
    ],
    "doc.client_name": [
      "sample_name"
    ],
    "doc.data_index_server": [
      " "
    ],
    "doc.client_name.keyword": [
      "citi"
    ],
    "doc.data_file_node_path.keyword": [
      " "
    ],
    "doc.client_id.keyword": [
      "0935be6b-61fe-4ec4-80c8-5c5ee8384378"
    ],
    "doc.data_index_server.keyword": [
      " "
    ],
    "doc.data_file_node_path": [
      " "
    ]
  }
}

my request for search is this.我的搜索请求是这样的。 and if I am taking some part of the ID and search against it.如果我正在使用 ID 的某些部分并对其进行搜索。 I am expecting to be hits will be zero我预计点击率将为零

POST /client_index/_search

    {
      "query": {
          "match": {
              "doc.client_id":"0935be6b-61fe-4ec4-80c8" ,
          }
      }
    }

I have follwed this url: How to make elastic search only match full field .我已经关注了这个 url: How to make elastic search only match full field change the fields type to keywords and also toggled index between true and false, but no result将字段类型更改为关键字,并在 true 和 false 之间切换索引,但没有结果

I think you have mixed up few things, in the mapping you showed just four properties which are simple fields, while in the search response, it has additional fields under fields which are of type object .我认为您混淆了一些东西,在映射中您只显示了四个属性,它们是简单的字段,而在搜索响应中,它在类型为objectfields下有其他字段。

You read it correct, keyword fields are not analyzed and on these fields you will get results only on full field value.您没看错, keyword字段未被分析,在这些字段上您将仅获得完整字段值的结果。

You should just try to define your client-id as a keyword field in new index with your sample field and search on that index to see it in action.您应该尝试将您的client-id定义为带有示例字段的新索引中的关键字字段,然后搜索该索引以查看它的实际效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM