Elastic Search with GUID

Hi

I am trying to search with a column having GIUD as value

Search Query

ElasticsearchResponse<string> objElasticResponse = objClient.Search<string>("pupil", "pupil", @"
            {
                ""query"" : {
                    ""bool"": {
                        ""must"" : [
                                      {
                                          ""match"": {
                                            ""Class.ClassId"": ""BD4C13B1-16EC-4E87-A7D9-9A0DF69EC8A8""
                                          }
                                      }
                            ]
                    }
                }
            }");

Result I got

{
  "took": 33,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 3,
    "max_score": 39.44093,
    "hits": [
      {
        "_index": "pupil",
        "_type": "pupil",
        "_id": "15EA34B5-4AFD-42F7-B949-D3C6E7992EA5",
        "_score": 7.4074607,
        "_source": {
          "Name": "aaa",
          "FirstName": "bbb",
          "ClassId": "BD4C13B1-16EC-4E87-A7D9-9A0DF69EC8A8",
          "IsEditable": "true",
          "Class": [
            {
              "ClassId": "BD4C13B1-16EC-4E87-A7D9-9A0DF69EC8A8",
              "PupilId": "15EA34B5-4AFD-42F7-B949-D3C6E7992EA5",
              "IsDeleted": "N"
            }
          ]
        }
      },
      {
        "_index": "pupil",
        "_type": "pupil",
        "_id": "698898F9-FBB0-4DE5-935D-E3422056D0CC",
        "_score": 7.4074607,
        "_source": {
          "Name": "ccc",
          "FirstName": "ddd",
          "ClassId": "21B2DD70-E228-406B-A7D9-5FB2E25E9AF9",
          "IsEditable": "true",
          "Class": [
            {
              "ClassId": "21B2DD70-E228-406B-A7D9-5FB2E25E9AF9",
              "PupilId": "698898F9-FBB0-4DE5-935D-E3422056D0CC",
              "IsDeleted": "N"
            }
          ]
        }
      },
      {
        "_index": "pupil",
        "_type": "pupil",
        "_id": "2B98763A-4348-4408-9069-58CD4B5AD68E",
        "_score": 7.4074607,
        "_source": {
          "Name": "eee",
          "FirstName": "fff",
          "ClassId": "BD4C13B1-D724-48D5-8F16-A47C36A10B31",
          "IsEditable": "true",
          "Class": [
            {
              "ClassId": "FEAC328B-D724-48D5-8F16-A47C36A10B31",
              "PupilId": "2B98763A-4348-4408-9069-58CD4B5AD68E",
              "IsDeleted": "N"
            },
            {
              "ClassId": "BD4C13B1-D724-48D5-8F16-A47C36A10B31",
              "PupilId": "2B98763A-4348-4408-9069-58CD4B5AD68E",
              "IsDeleted": "N"
            }
          ]
        }
      }
    ]
  }
}

I need exact match, but here results are wrong. "-" creating issue. It matches substrings ("-").

Any solution for this?

Thanks
Aneesh L

Class.ClassId is probably mapped as a text field which means it has been analysed. If you are using dynamic mapping you may be able to instead use Class.ClassId.keyword.

Hi Christian_Dahlqvist

Thanks it worked

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.