Failed to find type for field [geometry]

OpenSearch - 2.11 (relevant - OpenSearch/Dashboard/Server OS/Browser):

I am facing an issue with the GeoJSON search.

  "took": 94,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 0,
    "hits": [
      {
        "_index": "fp",
        "_type": "_doc",
        "_id": "1130012_FP",
        "_score": 0,
        "_source": {
          "type": "Feature",
          "properties": {
            "store": "TEST PONTIAN ",
            "corporate_id": 1130012,
            "index_type": "fp",
            "zone": "",
            "stroke": "#808080",
            "stroke-width": 2,
            "stroke-opacity": 1,
            "fill": "#ffff00",
            "fill-opacity": 0.5
          },
          "geometry": {
            "type": "Polygon",
            "coordinates": [
              [
                [
                  103.37952124489,
                  1.5152004382276
                ],
                [
                  103.37952123411,
                  1.5152003427942
                ],
                [
                  103.37907229304,
                  1.5112265541611
                ],
                [
                  103.379072,
                  1.511229
                ],
                [
                  103.3790721466,
                  1.5112252578998
                ],
                [
                  103.379065,
                  1.511162
                ],
                [
                  103.37907622082,
                  1.5111212580118
                ],
                [
                  103.379091,
                  1.510744
                ],
                [
                  103.379338,
                  1.50775
                ],
                [
                  103.380664,
                  1.504353
                ],
                [
                  103.382018,
                  1.502443
                ],
                [
                  103.381037,
                  1.502048
                ],
                [
                  103.38132,
                  1.50091
                ],
                [
                  103.382156,
                  1.500328
                ],
                [
                  103.38216,
                  1.49982
                ],
                [
                  103.384667,
                  1.499212
                ],
                [
                  103.386063,
                  1.495464
                ],
                [
                  103.386063,
                  1.492877375
                ],
                [
                  103.38606299984,
                  1.4928773747059
                ],
                [
                  103.38606299963,
                  1.4928773743202
                ],
                [
                  103.3860629996,
                  1.4928773742564
                ],
                [
                  103.38606299957,
                  1.4928773742028
                ],
                [
                  103.38606299661,
                  1.4928773687032
                ],
                [
                  103.38606298162,
                  1.4928773409121
                ],
                [
                  103.38606297827,
                  1.4928773346863
                ],
                [
                  103.38606284388,
                  1.4928770854149
                ],
                [
                  103.3860614634,
                  1.4928745247944
                ],
                [
                  103.38604791702,
                  1.4928493979919
                ],
                [
                  103.38592368749,
                  1.4926189679994
                ],
                [
                  103.385894,
                  1.492604
                ],
                [
                  103.385473,
                  1.491783
                ],
                [
                  103.38566,
                  1.489616
                ],
                [
                  103.385984,
                  1.488535
                ],
                [
                  103.387633,
                  1.486009
                ],
                [
                  103.390077,
                  1.484153
                ],
                [
                  103.389629,
                  1.481666
                ],
                [
                  103.38965204228,
                  1.4816522563444
                ],
                [
                  103.389548,
                  1.48104
                ],
                [
                  103.387286,
                  1.480539
                ],
                [
                  103.38524316477,
                  1.4811924799774
                ],
                [
                  103.382839,
                  1.482913
                ],
                [
                  103.382702,
                  1.481937
                ],
                [
                  103.3827521309,
                  1.4817477558554
                ],
                [
                  103.38275302071,
                  1.4817443968326
                ],
                [
                  103.382822,
                  1.481484
                ],
                [
                  103.38282600688,
                  1.48147576051
                ],
                [
                  103.382826,
                  1.481475
                ],
                [
                  103.38282707294,
                  1.4814735683226
                ],
                [
                  103.382893,
                  1.481338
                ],
                [
                  103.382962,
                  1.481198
                ],
                [
                  103.383481,
                  1.480601
                ],
                [
                  103.38458317488,
                  1.4803080342131
                ],
                [
                  103.384531,
                  1.48022
                ],
                [
                  103.385885,
                  1.479962
                ],
                [
                  103.387537,
                  1.479058
                ],
                [
                  103.38774206826,
                  1.4781347114313
                ],
                [
                  103.387626,
                  1.47804
                ],
                [
                  103.387963,
                  1.47714
                ],
                [
                  103.390935,
                  1.477682
                ],
                [
                  103.391967,
                  1.477299
                ],
                [
                  103.392786,
                  1.477403
                ],
                [
                  103.393971,
                  1.476109
                ],
                [
                  103.39398936274,
                  1.476265547018
                ],
                [
                  103.394557,
                  1.475729
                ],
                [
                  103.393136,
                  1.473666
                ],
                [
                  103.394528,
                  1.473999
                ],
                [
                  103.396584,
                  1.47122
                ],
                [
                  103.39593763934,
                  1.4724054306824
                ],
                [
                  103.396444,
                  1.471833
                ],
                [
                  103.397011,
                  1.470455
                ],
                [
                  103.39618,
                  1.467582
                ],
                [
                  103.39693,
                  1.465797
                ],
                [
                  103.399045,
                  1.463346
                ],
                [
                  103.399801,
                  1.461109
                ],
                [
                  103.40462682076,
                  1.4545293189799
                ],
                [
                  103.4049092,
                  1.4547708
                ],
                [
                  103.4113894,
                  1.4571303
                ],
                [
                  103.4107457,
                  1.4608199
                ],
                [
                  103.4094582,
                  1.4635655
                ],
                [
                  103.4129344,
                  1.4649813
                ],
                [
                  103.4157668,
                  1.4663541
                ],
                [
                  103.4188567,
                  1.4645523
                ],
                [
                  103.4226762,
                  1.4612489
                ],
                [
                  103.42303641877,
                  1.4608487640026
                ],
                [
                  103.423031,
                  1.460896
                ],
                [
                  103.4218163573,
                  1.4622751490413
                ],
                [
                  103.422362,
                  1.461824
                ],
                [
                  103.42176757998,
                  1.4623305325659
                ],
                [
                  103.421414,
                  1.462732
                ],
                [
                  103.42566,
                  1.467243
                ],
                [
                  103.423553,
                  1.46858
                ],
                [
                  103.422416,
                  1.470342
                ],
                [
                  103.429084,
                  1.47358
                ],
                [
                  103.42840926199,
                  1.4749252212405
                ],
                [
                  103.42748549663,
                  1.4767669268528
                ],
                [
                  103.42747055485,
                  1.4768376550182
                ],
                [
                  103.426996,
                  1.479084
                ],
                [
                  103.42864,
                  1.480608
                ],
                [
                  103.42734,
                  1.484688
                ],
                [
                  103.428563,
                  1.485131
                ],
                [
                  103.428801,
                  1.488111
                ],
                [
                  103.432572,
                  1.493181
                ],
                [
                  103.429986,
                  1.493124
                ],
                [
                  103.428676,
                  1.495227
                ],
                [
                  103.426251,
                  1.497829
                ],
                [
                  103.42557286898,
                  1.4991128961174
                ],
                [
                  103.42556545152,
                  1.4999562045643
                ],
                [
                  103.42555518175,
                  1.5011237983285
                ],
                [
                  103.429149,
                  1.504201
                ],
                [
                  103.43108068266,
                  1.5063632664068
                ],
                [
                  103.432606,
                  1.50736
                ],
                [
                  103.433923,
                  1.50599
                ],
                [
                  103.43428888899,
                  1.5064137103409
                ],
                [
                  103.4337483,
                  1.5080109
                ],
                [
                  103.4321175,
                  1.5074961
                ],
                [
                  103.4302722,
                  1.5062949
                ],
                [
                  103.4290491,
                  1.5044287
                ],
                [
                  103.424264,
                  1.5017903
                ],
                [
                  103.4233628,
                  1.500203
                ],
                [
                  103.420745,
                  1.4994522
                ],
                [
                  103.416668,
                  1.4982296
                ],
                [
                  103.4137068,
                  1.4972858
                ],
                [
                  103.4104882,
                  1.4970283
                ],
                [
                  103.4077417,
                  1.5042357
                ],
                [
                  103.4109603,
                  1.5080538
                ],
                [
                  103.4091793,
                  1.5103061
                ],
                [
                  103.407055,
                  1.5085901
                ],
                [
                  103.4048663,
                  1.5073459
                ],
                [
                  103.4037934,
                  1.5100487
                ],
                [
                  103.3951245,
                  1.5044716
                ],
                [
                  103.3936225,
                  1.5091049
                ],
                [
                  103.3898888,
                  1.5127085
                ],
                [
                  103.3853559,
                  1.5172291
                ],
                [
                  103.3827847385,
                  1.5211382415462
                ],
                [
                  103.38237405985,
                  1.5208274724394
                ],
                [
                  103.379967,
                  1.519006
                ],
                [
                  103.3781187338,
                  1.519708040012
                ],
                [
                  103.37810262373,
                  1.5197141592148
                ],
                [
                  103.37684642179,
                  1.5212388899255
                ],
                [
                  103.37625170062,
                  1.5220034598656
                ],
                [
                  103.37583063873,
                  1.5217122397204
                ],
                [
                  103.37952124489,
                  1.5152004382276
                ]
              ]
            ]
          }
        }
      }
    ]
  }
}```

Search Query:

```curl --location --request GET '127.0.0.1:9200/fp/_search' \--header 'Content-Type: application/json' \--header 'Cookie: mage-messages=%5B%7B%22type%22%3A%22error%22%2C%22text%22%3A%22Invalid%20Form%20Key.%20Please%20refresh%20the%20page.%22%7D%5D' \--data-raw '{"query":{"bool":{"filter":{"geo_shape":{"geometry":{"shape":{"type":"point","coordinates":[103.4018,1.5004]}}}}}}}'```

```{
  "error": {
    "root_cause": [
      {
        "type": "query_shard_exception",
        "reason": "failed to find type for field [geometry]",
        "index": "fp",
        "index_uuid": "GVsvdRXyQbechH6EjObtlQ"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "fp",
        "node": "nSMQTc4UQ0-yhM1pGN3oaA",
        "reason": {
          "type": "query_shard_exception",
          "reason": "failed to find type for field [geometry]",
          "index": "fp",
          "index_uuid": "GVsvdRXyQbechH6EjObtlQ"
        }
      }
    ]
  },
  "status": 400
}```

Configuration:

**


**:

Hey @shadaba20

Looks like all shards failed. Whats your Opensearch status look like?

Hey @Gsmitt ,

It would be very much appreciated if you please help me out from here.

Below is the shard info of fp index:

curl localhost:9200/_cat/shards/fp
fp 0 p STARTED 0 208b 127.0.0.1 shad
fp 0 r UNASSIGNED

I have done Google around shard and done some work but still not working.
For more info please check the attached images.

pawan@kfc:/var/www/html/projects/magento-cloud$ curl localhost:9200/_cluster/health | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   461  100   461    0     0  22030      0 --:--:-- --:--:-- --:--:-- 28812
{
  "cluster_name": "opensearch",
  "status": "yellow",
  "timed_out": false,
  "number_of_nodes": 1,
  "number_of_data_nodes": 1,
  "discovered_master": true,
  "discovered_cluster_manager": true,
  "active_primary_shards": 15,
  "active_shards": 15,
  "relocating_shards": 0,
  "initializing_shards": 0,
  "unassigned_shards": 24,
  "delayed_unassigned_shards": 0,
  "number_of_pending_tasks": 0,
  "number_of_in_flight_fetch": 0,
  "task_max_waiting_in_queue_millis": 0,
  "active_shards_percent_as_number": 38.46153846153847
}
pawan@kfc:/var/www/html/projects/magento-cloud$ curl localhost:9200/_cluster/health/fp | jq                                     % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   459  100   459    0     0   6240      0 --:--:-- --:--:-- --:--:--  7913
{
  "cluster_name": "opensearch",
  "status": "yellow",
  "timed_out": false,
  "number_of_nodes": 1,
  "number_of_data_nodes": 1,
  "discovered_master": true,
  "discovered_cluster_manager": true,
  "active_primary_shards": 6,
  "active_shards": 6,
  "relocating_shards": 0,
  "initializing_shards": 0,
  "unassigned_shards": 12,
  "delayed_unassigned_shards": 0,
  "number_of_pending_tasks": 0,
  "number_of_in_flight_fetch": 0,
  "task_max_waiting_in_queue_millis": 0,
  "active_shards_percent_as_number": 38.46153846153847
}

Hey @shadaba20

Is this one node, If so why is there two different Active primary shards"active_primary_shards": 15, "active_primary_shards": 6?

EDIT: I assume you working on this?

1 Like

@shadaba20 Did you follow the Geoshape documentation as suggested by @Gsmitt

I think your issue might be related to the type of the field. As per documentation, your geometry field must be geo_shape type.

I’ve tested your example with proper mapping and it worked.

PUT /fp
{
  "mappings": {
    "properties": {
      "geometry": {
        "type": "geo_shape"
      }
    }
  }
}
GET fp

{
  "fp": {
    "aliases": {},
    "mappings": {
      "properties": {
        "geometry": {
          "type": "geo_shape"
        }
      }
    },
    "settings": {
      "index": {
        "replication": {
          "type": "DOCUMENT"
        },
        "number_of_shards": "1",
        "provided_name": "fp",
        "creation_date": "1699491548569",
        "number_of_replicas": "1",
        "uuid": "HCHJ0diFQ0aAekHN6b8ImQ",
        "version": {
          "created": "136327827"
        }
      }
    }
  }
}
POST fp/_doc
      {
          "geometry": {
            "type": "Polygon",
            "coordinates": [
              [
                [
                  103.37952124489,
                  1.5152004382276
                ],
                [
                  103.37952123411,
                  1.5152003427942
                ],
                [
                  103.37907229304,
                  1.5112265541611
                ],
                [
                  103.379072,
                  1.511229
                ],
                [
                  103.3790721466,
                  1.5112252578998
                ],
                [
                  103.379065,
                  1.511162
                ],
                [
                  103.37907622082,
                  1.5111212580118
                ],
                [
                  103.379091,
                  1.510744
                ],
                [
                  103.379338,
                  1.50775
                ],
                [
                  103.380664,
                  1.504353
                ],
                [
                  103.382018,
                  1.502443
                ],
                [
                  103.381037,
                  1.502048
                ],
                [
                  103.38132,
                  1.50091
                ],
                [
                  103.382156,
                  1.500328
                ],
                [
                  103.38216,
                  1.49982
                ],
                [
                  103.384667,
                  1.499212
                ],
                [
                  103.386063,
                  1.495464
                ],
                [
                  103.386063,
                  1.492877375
                ],
                [
                  103.38606299984,
                  1.4928773747059
                ],
                [
                  103.38606299963,
                  1.4928773743202
                ],
                [
                  103.3860629996,
                  1.4928773742564
                ],
                [
                  103.38606299957,
                  1.4928773742028
                ],
                [
                  103.38606299661,
                  1.4928773687032
                ],
                [
                  103.38606298162,
                  1.4928773409121
                ],
                [
                  103.38606297827,
                  1.4928773346863
                ],
                [
                  103.38606284388,
                  1.4928770854149
                ],
                [
                  103.3860614634,
                  1.4928745247944
                ],
                [
                  103.38604791702,
                  1.4928493979919
                ],
                [
                  103.38592368749,
                  1.4926189679994
                ],
                [
                  103.385894,
                  1.492604
                ],
                [
                  103.385473,
                  1.491783
                ],
                [
                  103.38566,
                  1.489616
                ],
                [
                  103.385984,
                  1.488535
                ],
                [
                  103.387633,
                  1.486009
                ],
                [
                  103.390077,
                  1.484153
                ],
                [
                  103.389629,
                  1.481666
                ],
                [
                  103.38965204228,
                  1.4816522563444
                ],
                [
                  103.389548,
                  1.48104
                ],
                [
                  103.387286,
                  1.480539
                ],
                [
                  103.38524316477,
                  1.4811924799774
                ],
                [
                  103.382839,
                  1.482913
                ],
                [
                  103.382702,
                  1.481937
                ],
                [
                  103.3827521309,
                  1.4817477558554
                ],
                [
                  103.38275302071,
                  1.4817443968326
                ],
                [
                  103.382822,
                  1.481484
                ],
                [
                  103.38282600688,
                  1.48147576051
                ],
                [
                  103.382826,
                  1.481475
                ],
                [
                  103.38282707294,
                  1.4814735683226
                ],
                [
                  103.382893,
                  1.481338
                ],
                [
                  103.382962,
                  1.481198
                ],
                [
                  103.383481,
                  1.480601
                ],
                [
                  103.38458317488,
                  1.4803080342131
                ],
                [
                  103.384531,
                  1.48022
                ],
                [
                  103.385885,
                  1.479962
                ],
                [
                  103.387537,
                  1.479058
                ],
                [
                  103.38774206826,
                  1.4781347114313
                ],
                [
                  103.387626,
                  1.47804
                ],
                [
                  103.387963,
                  1.47714
                ],
                [
                  103.390935,
                  1.477682
                ],
                [
                  103.391967,
                  1.477299
                ],
                [
                  103.392786,
                  1.477403
                ],
                [
                  103.393971,
                  1.476109
                ],
                [
                  103.39398936274,
                  1.476265547018
                ],
                [
                  103.394557,
                  1.475729
                ],
                [
                  103.393136,
                  1.473666
                ],
                [
                  103.394528,
                  1.473999
                ],
                [
                  103.396584,
                  1.47122
                ],
                [
                  103.39593763934,
                  1.4724054306824
                ],
                [
                  103.396444,
                  1.471833
                ],
                [
                  103.397011,
                  1.470455
                ],
                [
                  103.39618,
                  1.467582
                ],
                [
                  103.39693,
                  1.465797
                ],
                [
                  103.399045,
                  1.463346
                ],
                [
                  103.399801,
                  1.461109
                ],
                [
                  103.40462682076,
                  1.4545293189799
                ],
                [
                  103.4049092,
                  1.4547708
                ],
                [
                  103.4113894,
                  1.4571303
                ],
                [
                  103.4107457,
                  1.4608199
                ],
                [
                  103.4094582,
                  1.4635655
                ],
                [
                  103.4129344,
                  1.4649813
                ],
                [
                  103.4157668,
                  1.4663541
                ],
                [
                  103.4188567,
                  1.4645523
                ],
                [
                  103.4226762,
                  1.4612489
                ],
                [
                  103.42303641877,
                  1.4608487640026
                ],
                [
                  103.423031,
                  1.460896
                ],
                [
                  103.4218163573,
                  1.4622751490413
                ],
                [
                  103.422362,
                  1.461824
                ],
                [
                  103.42176757998,
                  1.4623305325659
                ],
                [
                  103.421414,
                  1.462732
                ],
                [
                  103.42566,
                  1.467243
                ],
                [
                  103.423553,
                  1.46858
                ],
                [
                  103.422416,
                  1.470342
                ],
                [
                  103.429084,
                  1.47358
                ],
                [
                  103.42840926199,
                  1.4749252212405
                ],
                [
                  103.42748549663,
                  1.4767669268528
                ],
                [
                  103.42747055485,
                  1.4768376550182
                ],
                [
                  103.426996,
                  1.479084
                ],
                [
                  103.42864,
                  1.480608
                ],
                [
                  103.42734,
                  1.484688
                ],
                [
                  103.428563,
                  1.485131
                ],
                [
                  103.428801,
                  1.488111
                ],
                [
                  103.432572,
                  1.493181
                ],
                [
                  103.429986,
                  1.493124
                ],
                [
                  103.428676,
                  1.495227
                ],
                [
                  103.426251,
                  1.497829
                ],
                [
                  103.42557286898,
                  1.4991128961174
                ],
                [
                  103.42556545152,
                  1.4999562045643
                ],
                [
                  103.42555518175,
                  1.5011237983285
                ],
                [
                  103.429149,
                  1.504201
                ],
                [
                  103.43108068266,
                  1.5063632664068
                ],
                [
                  103.432606,
                  1.50736
                ],
                [
                  103.433923,
                  1.50599
                ],
                [
                  103.43428888899,
                  1.5064137103409
                ],
                [
                  103.4337483,
                  1.5080109
                ],
                [
                  103.4321175,
                  1.5074961
                ],
                [
                  103.4302722,
                  1.5062949
                ],
                [
                  103.4290491,
                  1.5044287
                ],
                [
                  103.424264,
                  1.5017903
                ],
                [
                  103.4233628,
                  1.500203
                ],
                [
                  103.420745,
                  1.4994522
                ],
                [
                  103.416668,
                  1.4982296
                ],
                [
                  103.4137068,
                  1.4972858
                ],
                [
                  103.4104882,
                  1.4970283
                ],
                [
                  103.4077417,
                  1.5042357
                ],
                [
                  103.4109603,
                  1.5080538
                ],
                [
                  103.4091793,
                  1.5103061
                ],
                [
                  103.407055,
                  1.5085901
                ],
                [
                  103.4048663,
                  1.5073459
                ],
                [
                  103.4037934,
                  1.5100487
                ],
                [
                  103.3951245,
                  1.5044716
                ],
                [
                  103.3936225,
                  1.5091049
                ],
                [
                  103.3898888,
                  1.5127085
                ],
                [
                  103.3853559,
                  1.5172291
                ],
                [
                  103.3827847385,
                  1.5211382415462
                ],
                [
                  103.38237405985,
                  1.5208274724394
                ],
                [
                  103.379967,
                  1.519006
                ],
                [
                  103.3781187338,
                  1.519708040012
                ],
                [
                  103.37810262373,
                  1.5197141592148
                ],
                [
                  103.37684642179,
                  1.5212388899255
                ],
                [
                  103.37625170062,
                  1.5220034598656
                ],
                [
                  103.37583063873,
                  1.5217122397204
                ],
                [
                  103.37952124489,
                  1.5152004382276
                ]
              ]
            ]
          }
        }
GET fp/_search 
{
  "query":
  {
    "bool":
    {
      "filter":
      {
        "geo_shape":
        {
          "geometry":
          {
            "shape":
            {
              "type":"point",
              "coordinates":[103.4018,1.5004]
            }
          }
        }
      }
    }
  }
}
Response 
{
  "took": 350,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 0,
    "hits": [
      {
        "_index": "fp",
        "_id": "WiyYsYsBTNyukQKozx9p",
        "_score": 0,
        "_source": {
          "geometry": {
            "type": "Polygon",
            "coordinates": [
              [
                [
                  103.37952124489,
                  1.5152004382276
                ],
                [
                  103.37952123411,
                  1.5152003427942
                ],
...
2 Likes

@pablo & @Gsmitt thanks for your help

curl -X PUT localhost:9200/fp -H "Content-type: application/json" -d '{"mappings": {"properties": {"geometry": {"type": "geo_shape"}}}}' | jq 

Working now.

Thanks again.

1 Like