作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 flex 搜索中有一个索引,希望得到特定的驾驶员年龄人士。我执行以下查询以获取drv_age = 63
library(elasticsearchr)
# Required variables;
index.name <- "acturial"
index.type <- "data"
col.name <- "drv_age"
value <- 63
# Path where result will be written in json form;
path <- "G:\\R Projects\\Elastic Search R\\Record.json"
myQuery <- paste0('{ "match" : {"', col.name, '" : ', value , '} } ')
# reading data from elasticSearch
data <- elastic("http://localhost:9200", index.name, index.type) %search% query(myQuery)
Error in extract_function(initial_response) : no query results returned
最佳答案
使用R中 flex 包装的搜索方法,我们可以获得针对某个查询的总点击量。这样,我们可以检查是否找到任何数据。以下是代码段。
library(elastic)
connect()
# Required variables;
index.name <- "acturial"
index.type <- "data"
col.name <- "year"
value <- "2013"
myQuery <- paste(col.name,value,sep = ":")
records.found <- Search(index.name,index.type,q=myQuery)$hits$total
if (records.found > 0){
# Your loggic;
}else{
print("No record found")
}
关于r - extract_function(initial_response)中的错误:R中的elasticsearchr中没有返回查询结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47261392/
我在 flex 搜索中有一个索引,希望得到特定的驾驶员年龄人士。我执行以下查询以获取drv_age = 63 library(elasticsearchr) # Required variables;
我是一名优秀的程序员,十分优秀!