Geo_shape index cannot convert by avro (nifi)

I use json like this:
[{"scene_id":"LC81121092020347LGN00","data_path":112,"data_row":109,"upper_left_lon":95.20724,"upper_left_lat":-68.44105,"upper_right_lon":99.64702,"upper_right_lat":-69.16904,"lower_right_lon":97.65649,"lower_right_lat":-70.76711,"lower_left_lon":92.94828,"lower_left_lat":-69.98763,"ingestion_date":"2020-12-12","browser_url":"https://ims.cr.usgs.gov/browse/landsat_8_c1/2020/112/109/LC08_L1GT_112109_20201212_20201214_01_RT.jpg","sensor":"OLI_TIRS","product_id":"LC08_L1GT_112109_20201212_20201214_01_RT","geometry":"{\"coordinates\":[[[-177.0,10.0],[176.0,15.0],[172.0,0.0],[176.0,-15.0],[-177.0,-10.0],[-177.0,10.0]],[[178.2,8.2],[-178.8,8.2],[-180.8,-8.8],[178.2,8.8]]],\"type\":\"polygon\"}"}]
the "geometry" is a string.
I want to index this json with mapping:

  `  {
    "mappings": {
        "data": {
            "properties": {
                "scene_id":{
                  "type" : "keyword",
                  "index" : false
                },
                "geometry": {
                    "type": "geo_shape"
                }
            }
        }
    }
}`

I used nifi professor and got the error:


It's so hard with avro schema to solve this,pls help me.thank you!

The problem is that your process is taking the generated geoJson and converting it to a string. I don't know much about Avro but you need to find a way so the GeoJSON is not treated as a String, or maybe try to generate WKT?

1 Like

Thank you for reply.I solved my problem with generate WKT.I trans it like:
POLYGON ((95.20724 -68.44105,99.64702 -69.16904,97.65649 -70.76711,92.94828 -69.98763,95.20724 -68.44105))
It work well,and the intersection is well done:
GET /landsat/_search { "query":{ "bool": { "must": { "match_all": {} }, "filter": { "geo_shape": { "geometry": { "shape": { "type": "polygon", "coordinates" : [[[96.0, -69.0],[96.0,-65.0],[97.0,-65.0],[97.0,-69],[96.0,-69.0]]] }, "relation": "INTERSECTS" } } } } } }
It's a good way for me.
Thank you very much for the help!
Have a good day!

1 Like

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