ropensci / elastic

R client for the Elasticsearch HTTP API
https://docs.ropensci.org/elastic
Other
245 stars 58 forks source link

index_analyze throwing incorrect warning when filters == NULL #269

Closed EmilBode closed 4 years ago

EmilBode commented 4 years ago

As in the title: For example index_analyze(my_inst, "sometext", analyzer='standard') will generate a warning (Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes. Consider 'structure(list(), *)' instead.)

As far as I can see, this is due to line 15 in index_analyze (line 478 in file R/index.R), where I(filters) and I(char_filters) is called. This is as I(NULL) generates the warning (as setting any attribute, including the class attribute, on NULL is invalid)

Proposed fix:

Add 2 lines between line 12 and 13:

if (!is.null(filters)) filters <- I(filters)
if (!is.null(char_filters)) char_filters <- I(char_filters)

And delete the I's in the next call (on line 15 but also on line 22)

Environment

Using elastic version 1.0.0 under R 3.6.1 and 3.6.2 Using Rstudio under windows

sckott commented 4 years ago

thanks for the report and proposed fix - fixed now. reinstall remotes::install_github("ropensci/elastic") and the warning should be gone