Select to view content in your preferred language

How to apply GroupBy And Distinct Queries in Geoportal ?

619
3
05-25-2022 11:48 PM
MahenderSingh
New Contributor II

Hi, I am using Elastic Search URL  to get metadata from ESRI Geoportal.

When I am Posting query in Geoportal it is returning single feature set as result and it's total count in DB( Feature set Count Exceeds Default Count :10000).

For Ex:- PayLoad Screenshot below.

MahenderSingh_0-1653546964827.png

Response Screenshot Below:

MahenderSingh_1-1653547057668.png

But For every Distinct Value against a Field in Metadata i am posting individual query with changed field value.

So to reduce the number of posted queries. 

Is there any way we can get all the distinct values against a tag and their respective counts in metadata using elastic search if any please reply.

.

0 Kudos
3 Replies
Marten
by
Occasional Contributor

Not sure exactly what you're trying to achieve, but with the elastic proxy API endpoint in Geoportal Server you can use aggregation queries following elastic's syntax. Below is an example:

{
    "aggregations": {
        "keywords_s_count": {
            "terms": {
                "field""keywords_s",
                "size"10
            }
        }
    }
}

POST this query to the elastic proxy api endpoint with your from and size values:

geoportal/elastic/metadata/item/_search?from=0&size=10

will result in something like below

    ...
  "aggregations": {
    "keywords_s_count": {
      "doc_count_error_upper_bound"0,
      "sum_other_doc_count"0,
      "buckets": [
        { key": "EARTH SCIENCE", "doc_count": 8},
        {"key""RIVERS/STREAMS""doc_count"4},
        {"key""SURFACE WATER","doc_count": 2},
        {"key""SURFACE WATER FEATURES","doc_count": 1}
      ]
    }
  }
}

 

0 Kudos
MahenderSingh
New Contributor II

Hi Marten, 

Thank you so much for your response on above asked question. we are expecting the same result which you have shared above.

and as suggested by you,

1. we have tried to replicate aggregation query as mentioned below :

 let aggregations = {
      "aggregations":
      {
        "src_Spatial_representation_type_s_count": {
          "terms": {
            "field": "src_Spatial_representation_type_txt_s"
          }
        }
      }
    };
 
But in response doc counts are 0 whereas it has abundant data in database.
MahenderSingh_0-1653925057118.png

 I am also attaching json sample as a reference if you to have a look.

2.  Is there any problem with terms aggregation if field type is not keyword and is in form _txt in place of _s.

 

 

0 Kudos
Marten
by
Occasional Contributor

please note that the field you are trying to get aggregation information for is called: src_Spatial_representation_type_txt, not src_Spatial_representation_type_txt_s

0 Kudos