elasticsearchr icon indicating copy to clipboard operation
elasticsearchr copied to clipboard

list_fields() always returns NULL

Open regisoc opened this issue 6 years ago • 3 comments

Hi,

I am trying to use the functions you listed in CRAN, everything seems to work pretty fine except the list_fields() using %info% infix.

I tried with the tidyverse mpg dataset to play small.

image

I use the version 7.4.0 of Elasticsearch (the latest).

Do I miss something?

regisoc avatar Oct 09 '19 21:10 regisoc

Found it.

In the file R/api.R, list_fields() function, line 189:

fields <- names(index_mapping[[1]]$mappings$data$properties)

must be changed by:

fields <- names(index_mapping[[1]]$mappings$properties)

When performed: image

regisoc avatar Oct 11 '19 13:10 regisoc

pull request sent, however I forgot to mention: it only works with ES 7.

Taking the same dataset as example (mpg from tidyverse), all the minor versions of ES have differences :

With ES 7.4.0: executing curl http://localhost:9200/mpg/_mapping?pretty

{
  "mpg" : {
    "mappings" : {
      "properties" : {
        "class" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "cty" : {
          "type" : "long"
        },
   ...
}

The hierarchy to reach fields name is: mpg > mappings > properties

With ES 6.8.3: executing curl http://localhost:9200/mpg/_mapping?pretty

{
  "mpg" : {
    "mappings" : {
      "mpg" : {
        "properties" : {
          "class" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
  ....
}

The hierarchy to reach fields name is: mpg > mappings > mpg > properties

regisoc avatar Oct 11 '19 13:10 regisoc

Yes, some serious development (together with a cogent plan), is required to make elasticsearchr compatible with ES 7.x.

AlexIoannides avatar Oct 13 '19 20:10 AlexIoannides