代码之家  ›  专栏  ›  技术社区  ›  ddxx

C#nest elasticsearch将guid转换为数组

  •  0
  • ddxx  · 技术社区  · 8 年前

    enter image description here 我在一个guid值为c4b0c9ae-345c-4247-87e3-e9d9de67c01b的字段上进行聚合,但当弹性搜索返回聚合时 它正在成为一个数组[“c4b0c9ae”、“345c”、“4247”、“87e3”、“e9d9de67c01b”]。 你在nest上是怎么处理的?

    1 回复  |  直到 8 年前
        1
  •  1
  •   Russ Cam    8 年前

    text datatype 在索引时进行分析,默认情况下使用 Standard Analyzer

    GET _analyze
    {
        "analyzer": "standard",
        "text": ["c4b0c9ae-345c-4247-87e3-e9d9de67c01b"]
    }
    

    产量

    {
       "tokens": [
          {
             "token": "c4b0c9ae",
             "start_offset": 0,
             "end_offset": 8,
             "type": "<ALPHANUM>",
             "position": 0
          },
          {
             "token": "345c",
             "start_offset": 9,
             "end_offset": 13,
             "type": "<ALPHANUM>",
             "position": 1
          },
          {
             "token": "4247",
             "start_offset": 14,
             "end_offset": 18,
             "type": "<NUM>",
             "position": 2
          },
          {
             "token": "87e3",
             "start_offset": 19,
             "end_offset": 23,
             "type": "<ALPHANUM>",
             "position": 3
          },
          {
             "token": "e9d9de67c01b",
             "start_offset": 24,
             "end_offset": 36,
             "type": "<ALPHANUM>",
             "position": 4
          }
       ]
    }
    

    您可能不想在索引时分析guid,所以应该 explicitly map them keyword datatype .