Error in crossprod(test$inc_rat, nation_agegroup2010$total_prop) : non-conformable arguments - boot

I run the following lines to obtain the bootstrapped standardized rate for a group of people, but it return a error that I can't solve after a couple of days.
Error in crossprod(test$inc_rat, nation_agegroup2010$total_prop) :
non-conformable arguments
# to build the dataset
ZN_2011NGT_ADA <- c(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
age_rage_ZN <- c("2", "3", "4", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "4", "4", "4", "4", "4", "4", "4", "2", "3", "4", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "5", "5", "5")
zzz <- data.frame(ZN_2011NGT_ADA, age_rage_ZN)
# define the function for bootstrap
ZN_boot <- function(total_dat, rows){
data <- total_dat[rows,]
test <- merge(aggregate(data$ZN_2011NGT_ADA, by = list(age = data$age_rage_ZN), length),
aggregate(data$ZN_2011NGT_ADA, by = list(age = data$age_rage_ZN), sum),
by = 'age')
test$inc_rat <- test$x.y/test$x.x
return(crossprod(test$inc_rat, nation_agegroup2010$total_prop))}
# to run bootstrap
library(boot)
set.seed(1234
boot(data = zzz, statistic = ZN_boot, R = 5000)
The purpose of this block of codes is to get the bootstrapped rate (the value that returned in the function after bootstrapping in the boot function). I run similar codes on other datasets and it turned out to be fine. I am wondering why the last code always reports the above mentioned error? Can anyone be of help?

Related

Compare two fields using elastic search 7

I don't have much idea about Elastic search. Can we compare two types of prices while fetching record from Elastic server. Here's the example
"hits": [
{
"_index": "magento2_default_catalog_product_20210531_051304",
"_type": "_doc",
"_id": "57",
"_score": 1.0,
"_source": {
"entity_id": "57",
"visibility": "4",
"price": [
{
"price": 1.0,
"original_price": 1.0,
"is_discount": false,
"customer_group_id": 0,
"tax_class_id": 2,
"final_price": 0.0,
"min_price": 1.0,
"max_price": 1.0
},
{
"price": 1.0,
"original_price": 1.0,
"is_discount": false,
"customer_group_id": 1,
"tax_class_id": 2,
"final_price": 0.0,
"min_price": 1.0,
"max_price": 1.0
},
{
"price": 1.0,
"original_price": 1.0,
"is_discount": false,
"customer_group_id": 2,
"tax_class_id": 2,
"final_price": 0.0,
"min_price": 1.0,
"max_price": 1.0
},
{
"price": 1.0,
"original_price": 1.0,
"is_discount": false,
"customer_group_id": 3,
"tax_class_id": 2,
"final_price": 0.0,
"min_price": 1.0,
"max_price": 1.0
}
]
"stock": {
"is_in_stock": true,
"qty": 0
}
}
},
{
"_index": "magento2_default_catalog_product_20210531_051304",
"_type": "_doc",
"_id": "91",
"_score": 1.0,
"_source": {
"entity_id": "91",
"visibility": "4",
"price": [
{
"price": 1.0,
"original_price": 1.0,
"is_discount": false,
"customer_group_id": 0,
"tax_class_id": 2,
"final_price": 0.0,
"min_price": 1.0,
"max_price": 1.0
},
{
"price": 1.0,
"original_price": 1.0,
"is_discount": false,
"customer_group_id": 1,
"tax_class_id": 2,
"final_price": 0.0,
"min_price": 1.0,
"max_price": 1.0
},
{
"price": 1.0,
"original_price": 1.0,
"is_discount": false,
"customer_group_id": 2,
"tax_class_id": 2,
"final_price": 0.0,
"min_price": 1.0,
"max_price": 1.0
},
{
"price": 1.0,
"original_price": 1.0,
"is_discount": false,
"customer_group_id": 3,
"tax_class_id": 2,
"final_price": 0.0,
"min_price": 1.0,
"max_price": 1.0
}
],
"stock": {
"is_in_stock": true,
"qty": 0
}
}
},
]
I have tons of records, now I need those records which have final_price lesser then price. Since price is an array type, I have customer group id and tax class id so I need to compare it with respective index. let's say I have customer group id as 0 and tax class id as 2 so it should compare price and final price from first index or matching index of price.
Appreciate if anybody can help here.
To be able to query Array inner object you should map your price as a Nested type, arrays of objects do not work as you would expect because you cannot query each object independently of the other objects in the array. If you need to be able to do this then you should use the nested data type instead of the object data type. you can find the solution here.
Also you can check ES official documentation about array and nested objects here.

Logstash filter query with if else

I am facing issues with Logstash filters:
I want to put a condition like following:
filter {
if [SPCI] == 79 {
mutate {
replace => { "RSRP79" => "%{SRSRP}" }
replace => { "RSRQ79" => "%{SRSRQ}" }
}
}
My dataset looks like:
{
"took": 29,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 22656,
"max_score": null,
"hits": [
{
"_index": "processed.radiosignal",
"_type": "_doc",
"_id": "v_FJQnYBEKhQVcwaCsCy",
"_version": 26,
"_score": null,
"_source": {
"ElapsedRT": 0,
"Alt": 0,
"Row": 0,
"RSRP116": "0",
"NRSRP": -103,
"#version": "1",
"Handover": 0,
"Time": "2020.12.08-11.34.49.14",
"NRSRQ": -13,
"SPCI": 79,
"SRSRP": -100,
"#timestamp": "2020-12-15T17:31:29.080Z",
"SRSRQ": -11,
"RSRP79": "0",
"NPLMN": "nullnull",
"NPCI": 116,
"RSRQ116": "0",
"Lat": 0,
"Long": 0,
"RSRQ79": "0"
},
"fields": {
"#timestamp": [
"2020-12-15T17:31:29.080Z"
]
},
"sort": [
1608053489080
]
}
The query is not performing as expected and if SRSRP == 79 is failing.
I am quite new to ELK and could not understand where is the issue.
Just to clarify, I am creating RSRP79 and RSRQ79 fields using alter plugin in previous step and it is working fine.

MongoDB Too slow at find by id query, for just 100000 items?

I have a collection with 100000(999996) documents and I'm using Laravel for integration,
When I want to find a document by its id, it take too long to respond. (something like >80ms)
I'm wondering why it must take too long for just 100k items?
and _id field is indexed.
what configurations I should set for better performance.
be aware I have some embeds in my document that embedded by Laravel model.
example of one of the documents:
{
"_id": ObjectId("5d88a2857c254f0256737f43"),
"name": "blcy",
"coach": null,
"line_up": 1,
"sponsor_id": "5d131dd37c254f1d007d01f0",
"last_online": ISODate("2019-09-23T10:46:29.000Z"),
"stadium": 1,
"active_stadium": 1,
"doctor": 1,
"active_doctor": 1,
"trainer": 1,
"coach_assistant": 1,
"active_coach_assistant": 1,
"fitness_coach": 1,
"active_fitness_coach": 1,
"leader": 1,
"active_leader": 1,
"executive_manager": 1,
"active_executive_manager": 1,
"strategy": 1,
"attack_tactic": 1,
"defence_tactic": 1,
"ticket_price": 5,
"user_id": "5d88a2847c254f0256737f42",
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"kit": {
"bg_color": 10,
"fg_color": 20,
"fg": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f44")
},
"logo": {
"bg_color": 10,
"fg_color": 20,
"fg": 1,
"bg": 11,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f45")
},
"players": [
{
"name": "بردیا رادمان",
"player_number": 7,
"age": 22,
"post": "G",
"talent": 2,
"shoot": 6,
"pass": 2,
"speed": 5,
"strength": 5,
"readiness": 100,
"technique": 6,
"head": 6,
"real_power": 83,
"power": 30,
"level": 2,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f46"),
"in_lineup": true,
"position": "G"
},
{
"name": "سعید قاضی",
"player_number": 1,
"age": 19,
"post": "G",
"talent": 5,
"shoot": 2,
"pass": 2,
"speed": 6,
"strength": 5,
"readiness": 100,
"technique": 6,
"head": 2,
"real_power": 69,
"power": 23,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f47")
},
{
"name": "علیرضا چلبی",
"player_number": 47,
"age": 19,
"post": "G",
"talent": 4,
"shoot": 4,
"pass": 3,
"speed": 4,
"strength": 3,
"readiness": 100,
"technique": 4,
"head": 3,
"real_power": 60,
"power": 21,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f48")
},
{
"name": "آذین اوستا",
"player_number": 52,
"age": 25,
"post": "G",
"talent": 4,
"shoot": 5,
"pass": 6,
"speed": 2,
"strength": 6,
"readiness": 100,
"technique": 2,
"head": 4,
"real_power": 91,
"power": 25,
"level": 2,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f49")
},
{
"name": "یاسین صفوی",
"player_number": 28,
"age": 20,
"post": "D",
"talent": 4,
"shoot": 5,
"pass": 4,
"speed": 3,
"strength": 4,
"readiness": 100,
"technique": 3,
"head": 4,
"real_power": 68,
"power": 23,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f4a"),
"in_lineup": true,
"position": "D"
},
{
"name": "خشایار نوبخت",
"player_number": 36,
"age": 17,
"post": "D",
"talent": 2,
"shoot": 6,
"pass": 5,
"speed": 3,
"strength": 5,
"readiness": 100,
"technique": 3,
"head": 3,
"real_power": 75,
"power": 25,
"level": 2,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f4b"),
"in_lineup": true,
"position": "D"
},
{
"name": "شجاع سحاب",
"player_number": 18,
"age": 23,
"post": "D",
"talent": 3,
"shoot": 4,
"pass": 2,
"speed": 2,
"strength": 3,
"readiness": 100,
"technique": 5,
"head": 4,
"real_power": 53,
"power": 20,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f4c"),
"in_lineup": true,
"position": "D"
},
{
"name": "رها فهمیده",
"player_number": 10,
"age": 26,
"post": "D",
"talent": 3,
"shoot": 5,
"pass": 5,
"speed": 3,
"strength": 5,
"readiness": 100,
"technique": 5,
"head": 3,
"real_power": 76,
"power": 26,
"level": 2,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f4d"),
"in_lineup": true,
"position": "D"
},
{
"name": "آذین عبدالکریمی",
"player_number": 32,
"age": 18,
"post": "D",
"talent": 2,
"shoot": 6,
"pass": 4,
"speed": 2,
"strength": 2,
"readiness": 100,
"technique": 6,
"head": 5,
"real_power": 59,
"power": 25,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f4e"),
"in_lineup": true,
"position": "D"
},
{
"name": "محمدرضا طالقانی",
"player_number": 22,
"age": 26,
"post": "D",
"talent": 5,
"shoot": 3,
"pass": 3,
"speed": 3,
"strength": 4,
"readiness": 100,
"technique": 6,
"head": 2,
"real_power": 60,
"power": 21,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f4f")
},
{
"name": "پارسا دستغیب",
"player_number": 9,
"age": 19,
"post": "D",
"talent": 1,
"shoot": 6,
"pass": 2,
"speed": 4,
"strength": 3,
"readiness": 100,
"technique": 6,
"head": 2,
"real_power": 58,
"power": 23,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f50")
},
{
"name": "فرشید پناهیان",
"player_number": 33,
"age": 26,
"post": "M",
"talent": 2,
"shoot": 2,
"pass": 6,
"speed": 2,
"strength": 4,
"readiness": 100,
"technique": 3,
"head": 6,
"real_power": 72,
"power": 23,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f51"),
"in_lineup": true,
"position": "M"
},
{
"name": "سپهر واعظ",
"player_number": 8,
"age": 26,
"post": "M",
"talent": 4,
"shoot": 4,
"pass": 3,
"speed": 3,
"strength": 2,
"readiness": 100,
"technique": 6,
"head": 6,
"real_power": 72,
"power": 24,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f52"),
"in_lineup": true,
"position": "M"
},
{
"name": "امیررضا کوشکی",
"player_number": 3,
"age": 26,
"post": "M",
"talent": 5,
"shoot": 4,
"pass": 2,
"speed": 6,
"strength": 3,
"readiness": 100,
"technique": 3,
"head": 4,
"real_power": 62,
"power": 22,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f53"),
"in_lineup": true,
"position": "M"
},
{
"name": "پدرام جنتی",
"player_number": 29,
"age": 24,
"post": "M",
"talent": 3,
"shoot": 2,
"pass": 4,
"speed": 5,
"strength": 4,
"readiness": 100,
"technique": 2,
"head": 4,
"real_power": 63,
"power": 21,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f54")
},
{
"name": "محمد علی‌آبادی",
"player_number": 13,
"age": 17,
"post": "M",
"talent": 1,
"shoot": 2,
"pass": 5,
"speed": 3,
"strength": 3,
"readiness": 100,
"technique": 4,
"head": 4,
"real_power": 68,
"power": 21,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f55")
},
{
"name": "سهیل فانی",
"player_number": 19,
"age": 25,
"post": "M",
"talent": 1,
"shoot": 2,
"pass": 3,
"speed": 4,
"strength": 4,
"readiness": 100,
"technique": 4,
"head": 5,
"real_power": 65,
"power": 22,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f56")
},
{
"name": "شهرام گنجی",
"player_number": 24,
"age": 17,
"post": "S",
"talent": 4,
"shoot": 6,
"pass": 3,
"speed": 6,
"strength": 2,
"readiness": 100,
"technique": 2,
"head": 2,
"real_power": 69,
"power": 21,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f57"),
"in_lineup": true,
"position": "S"
},
{
"name": "امیرمحمد سرافراز",
"player_number": 2,
"age": 21,
"post": "S",
"talent": 4,
"shoot": 6,
"pass": 2,
"speed": 5,
"strength": 4,
"readiness": 100,
"technique": 5,
"head": 5,
"real_power": 90,
"power": 27,
"level": 2,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f58"),
"in_lineup": true,
"position": "S"
},
{
"name": "فربد ارسباران",
"player_number": 20,
"age": 25,
"post": "S",
"talent": 2,
"shoot": 2,
"pass": 2,
"speed": 5,
"strength": 3,
"readiness": 100,
"technique": 4,
"head": 4,
"real_power": 65,
"power": 20,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f59")
},
{
"name": "فرشید الهام",
"player_number": 21,
"age": 24,
"post": "S",
"talent": 2,
"shoot": 4,
"pass": 3,
"speed": 6,
"strength": 2,
"readiness": 100,
"technique": 3,
"head": 6,
"real_power": 78,
"power": 24,
"level": 2,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f5a")
},
{
"name": "ساسان طریقت",
"player_number": 35,
"age": 17,
"post": "S",
"talent": 5,
"shoot": 2,
"pass": 5,
"speed": 4,
"strength": 2,
"readiness": 100,
"technique": 5,
"head": 6,
"real_power": 74,
"power": 24,
"level": 1,
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f5b")
}
],
"league_id": "5d88a2857c254f0256737f5d",
"league_name": "league-0-1",
"transactions": [
{
"amount": 120000,
"type": "coin",
"cash": 0,
"coin": 120000,
"description": "1",
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f5e")
},
{
"amount": 100,
"type": "cash",
"cash": 100,
"coin": 120000,
"description": "1",
"updated_at": ISODate("2019-09-23T10:46:29.000Z"),
"created_at": ISODate("2019-09-23T10:46:29.000Z"),
"_id": ObjectId("5d88a2857c254f0256737f5f")
}
],
"cash": 100,
"coin": 120000,
"fixtures": [
{
"league_name": "league-0-1",
"home_id": "5d88a2857c254f025673800f",
"guest_id": "5d88a2857c254f0256737f43",
"week_day": 1,
"weather_type": "sunny",
"home_goal": 0,
"guest_goal": 0,
"friendly": false,
"fixture_id": "5d89dff87c254f36ee3ae9ab",
"updated_at": ISODate("2019-09-24T09:20:56.000Z"),
"created_at": ISODate("2019-09-24T09:20:56.000Z"),
"_id": ObjectId("5d89dff87c254f36ee3ae9ad")
},
{
"league_name": "league-0-1",
"home_id": "5d88a2857c254f0256737f61",
"guest_id": "5d88a2857c254f0256737f43",
"week_day": 2,
"weather_type": "rainy",
"home_goal": 0,
"guest_goal": 0,
"friendly": false,
"fixture_id": "5d89dff87c254f36ee3ae9c0",
"updated_at": ISODate("2019-09-24T09:20:56.000Z"),
"created_at": ISODate("2019-09-24T09:20:56.000Z"),
"_id": ObjectId("5d89dff87c254f36ee3ae9c2")
},
{
"league_name": "league-0-1",
"home_id": "5d88a2857c254f0256737f43",
"guest_id": "5d88a2857c254f0256737f7e",
"week_day": 3,
"weather_type": "sunny",
"home_goal": 0,
"guest_goal": 0,
"friendly": false,
"fixture_id": "5d89dff87c254f36ee3ae9c6",
"updated_at": ISODate("2019-09-24T09:20:56.000Z"),
"created_at": ISODate("2019-09-24T09:20:56.000Z"),
"_id": ObjectId("5d89dff87c254f36ee3ae9c7")
},
{
"league_name": "league-0-1",
"home_id": "5d88a2857c254f0256737f9b",
"guest_id": "5d88a2857c254f0256737f43",
"week_day": 4,
"weather_type": "sunny",
"home_goal": 0,
"guest_goal": 0,
"friendly": false,
"fixture_id": "5d89dff87c254f36ee3ae9d5",
"updated_at": ISODate("2019-09-24T09:20:56.000Z"),
"created_at": ISODate("2019-09-24T09:20:56.000Z"),
"_id": ObjectId("5d89dff87c254f36ee3ae9d7")
},
{
"league_name": "league-0-1",
"home_id": "5d88a2857c254f0256737f43",
"guest_id": "5d88a2857c254f0256737fb8",
"week_day": 5,
"weather_type": "rainy",
"home_goal": null,
"guest_goal": null,
"friendly": false,
"fixture_id": "5d89dff87c254f36ee3ae9e1",
"updated_at": ISODate("2019-09-24T09:20:57.000Z"),
"created_at": ISODate("2019-09-24T09:20:57.000Z"),
"_id": ObjectId("5d89dff97c254f36ee3ae9e2")
},
{
"league_name": "league-0-1",
"home_id": "5d88a2857c254f0256737fd5",
"guest_id": "5d88a2857c254f0256737f43",
"week_day": 6,
"weather_type": "sunny",
"home_goal": null,
"guest_goal": null,
"friendly": false,
"fixture_id": "5d89dff97c254f36ee3ae9ea",
"updated_at": ISODate("2019-09-24T09:20:57.000Z"),
"created_at": ISODate("2019-09-24T09:20:57.000Z"),
"_id": ObjectId("5d89dff97c254f36ee3ae9ec")
},
{
"league_name": "league-0-1",
"home_id": "5d88a2857c254f0256737f43",
"guest_id": "5d88a2857c254f0256737ff2",
"week_day": 7,
"weather_type": "sunny",
"home_goal": null,
"guest_goal": null,
"friendly": false,
"fixture_id": "5d89dff97c254f36ee3ae9fc",
"updated_at": ISODate("2019-09-24T09:20:57.000Z"),
"created_at": ISODate("2019-09-24T09:20:57.000Z"),
"_id": ObjectId("5d89dff97c254f36ee3ae9fd")
}
]
}
Finding a team like this:
$team = Team::find($team['team_id']);
EDITED:
chunk methods and also cant help me cause i just want to find one document not getting all documents in one row.
Thanks.

gets.chomp find a string in a list

Is it possible to find a string in a list for a gets.chomp for if, elsif?
def number_problem()
puts "Please enter a number 1-100 for a phrase or word back!"
number = gets.chomp
mult_of_three = ["3", "6", "9", "12", "15", "18", "21", "24", "27", "30", "33", "36", "39", "42", "45", "48", "51", "54", "57", "60", "63", "66", "69", "72", "75", "78", "81", "84", "87", "90", "93", "96", "99"]
mult_of_five = ["5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"]
mult_of_both = ["15", "30", "45", "60", "75", "90"]
if number == mult_of_three
puts "Bit"
To find if an element is present in an Array, you can use include?. Here:
if mult_of_three.include?(number)
Example:
number = gets.chomp
36
# => "36"
mult_of_three.include?(number)
# => true
number = gets.chomp
98
# => "98"
mult_of_three.include?(number)
# => false

elastic search query not returning results when the field has double quotes

I execute this query
POST /_search {
"query":{
"filtered":{
"filter":{
"bool":{
"must":[
{
"term":{
"tpid":3
}
},
{
"term":{
"eapid":0
}
}
]
}
}
}
}
}
I get result like this
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 20,
"successful": 20,
"failed": 0
},
"hits": {
"total": 10633,
"max_score": 1,
"hits": [
{
"_index": "gss.aggregated.se.logstash-2014.11.04",
"_type": "gss.aggregated.se",
"_id": "v63uksmIRgG9bI5hgS5DIQ",
"_score": 1,
"_source": {
"blacklistAggregatedKey": {
"utcTimestamp": "2014-10-28T09:00",
"departureAirport": "OVB",
"arrivalAirport": "KRR",
"tpid": 3,
"eapid": 0,
"AdvancePurchaseWindow": 3,
"LengthOfStay": -1
},
"blacklistAggregatedValue": {
"searchCount": 1,
"blackListed": 0
},
"#version": "1",
"#timestamp": "2014-11-04T19:30:16.426Z",
"type": "gss.aggregated.se"
}
},
{
"_index": "gss.aggregated.se.logstash-2014.11.04",
"_type": "gss.aggregated.se",
"_id": "bu7I38_CRDG17sXVq3IR-g",
"_score": 1,
"_source": {
"blacklistAggregatedKey": {
"utcTimestamp": "2014-10-28T09:00",
"departureAirport": "OSL",
"arrivalAirport": "OSA",
"tpid": 3,
"eapid": 0,
"AdvancePurchaseWindow": 149,
"LengthOfStay": -1
},
"blacklistAggregatedValue": {
"searchCount": 1,
"blackListed": 0
},
"#version": "1",
"#timestamp": "2014-11-04T19:30:16.486Z",
"type": "gss.aggregated.se"
}
},
{
"_index": "gss.aggregated.se.logstash-2014.11.04",
"_type": "gss.aggregated.se",
"_id": "wWb9xFpuRASTWyaqm-q9Kw",
"_score": 1,
"_source": {
"blacklistAggregatedKey": {
"utcTimestamp": "2014-10-28T09:00",
"departureAirport": "OSL",
"arrivalAirport": "NYC",
"tpid": 3,
"eapid": 0,
"AdvancePurchaseWindow": 49,
"LengthOfStay": -1
},
"blacklistAggregatedValue": {
"searchCount": 1,
"blackListed": 0
},
"#version": "1",
"#timestamp": "2014-11-04T19:30:16.491Z",
"type": "gss.aggregated.se"
}
},
{
"_index": "gss.aggregated.se.logstash-2014.11.04",
"_type": "gss.aggregated.se",
"_id": "c1ULKWyhR0iYmaZ5unafKA",
"_score": 1,
"_source": {
"blacklistAggregatedKey": {
"utcTimestamp": "2014-10-28T09:00",
"departureAirport": "OSL",
"arrivalAirport": "MOW",
"tpid": 3,
"eapid": 0,
"AdvancePurchaseWindow": 16,
"LengthOfStay": -1
},
"blacklistAggregatedValue": {
"searchCount": 1,
"blackListed": 0
},
"#version": "1",
"#timestamp": "2014-11-04T19:30:16.495Z",
"type": "gss.aggregated.se"
}
},
{
"_index": "gss.aggregated.se.logstash-2014.11.04",
"_type": "gss.aggregated.se",
"_id": "BGuGnuXsSne6jB7_ith5Lg",
"_score": 1,
"_source": {
"blacklistAggregatedKey": {
"utcTimestamp": "2014-10-28T09:00",
"departureAirport": "OSL",
"arrivalAirport": "MEL",
"tpid": 3,
"eapid": 0,
"AdvancePurchaseWindow": 10,
"LengthOfStay": -1
},
"blacklistAggregatedValue": {
"searchCount": 2,
"blackListed": 0
},
"#version": "1",
"#timestamp": "2014-11-04T19:30:16.505Z",
"type": "gss.aggregated.se"
}
},
{
"_index": "gss.aggregated.se.logstash-2014.11.04",
"_type": "gss.aggregated.se",
"_id": "lHXm68TTTPG44dIskGCr-w",
"_score": 1,
"_source": {
"blacklistAggregatedKey": {
"utcTimestamp": "2014-10-28T09:00",
"departureAirport": "OSA",
"arrivalAirport": "STO",
"tpid": 3,
"eapid": 0,
"AdvancePurchaseWindow": 12,
"LengthOfStay": -1
},
"blacklistAggregatedValue": {
"searchCount": 1,
"blackListed": 0
},
"#version": "1",
"#timestamp": "2014-11-04T19:30:16.606Z",
"type": "gss.aggregated.se"
}
},
{
"_index": "gss.aggregated.se.logstash-2014.11.04",
"_type": "gss.aggregated.se",
"_id": "DewbkMq0Q22IsReLTRIXww",
"_score": 1,
"_source": {
"blacklistAggregatedKey": {
"utcTimestamp": "2014-10-28T09:00",
"departureAirport": "OSA",
"arrivalAirport": "NYC",
"tpid": 3,
"eapid": 0,
"AdvancePurchaseWindow": 3,
"LengthOfStay": -1
},
"blacklistAggregatedValue": {
"searchCount": 1,
"blackListed": 0
},
"#version": "1",
"#timestamp": "2014-11-04T19:30:16.623Z",
"type": "gss.aggregated.se"
}
},
{
"_index": "gss.aggregated.se.logstash-2014.11.04",
"_type": "gss.aggregated.se",
"_id": "tuCl1rEcT4W3dJ9Am-XvSw",
"_score": 1,
"_source": {
"blacklistAggregatedKey": {
"utcTimestamp": "2014-10-28T09:00",
"departureAirport": "OSA",
"arrivalAirport": "MEL",
"tpid": 3,
"eapid": 0,
"AdvancePurchaseWindow": 9,
"LengthOfStay": 30
},
"blacklistAggregatedValue": {
"searchCount": 25,
"blackListed": 0
},
"#version": "1",
"#timestamp": "2014-11-04T19:30:16.625Z",
"type": "gss.aggregated.se"
}
},
{
"_index": "gss.aggregated.se.logstash-2014.11.04",
"_type": "gss.aggregated.se",
"_id": "6-O9T3HuRYuSVD68_cVeCg",
"_score": 1,
"_source": {
"blacklistAggregatedKey": {
"utcTimestamp": "2014-10-28T09:00",
"departureAirport": "OKC",
"arrivalAirport": "PHX",
"tpid": 3,
"eapid": 0,
"AdvancePurchaseWindow": 126,
"LengthOfStay": 7
},
"blacklistAggregatedValue": {
"searchCount": 1,
"blackListed": 0
},
"#version": "1",
"#timestamp": "2014-11-04T19:30:16.787Z",
"type": "gss.aggregated.se"
}
},
{
"_index": "gss.aggregated.se.logstash-2014.11.04",
"_type": "gss.aggregated.se",
"_id": "5_bGAZxdRIy5kAR5XuV70A",
"_score": 1,
"_source": {
"blacklistAggregatedKey": {
"utcTimestamp": "2014-10-28T09:00",
"departureAirport": "NYC",
"arrivalAirport": "QLA",
"tpid": 3,
"eapid": 0,
"AdvancePurchaseWindow": 11,
"LengthOfStay": -1
},
"blacklistAggregatedValue": {
"searchCount": 1,
"blackListed": 0
},
"#version": "1",
"#timestamp": "2014-11-04T19:30:16.862Z",
"type": "gss.aggregated.se"
}
}
]
}
}
I want to filter this further by departure airport. when I try
POST /_search
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"tpid": 3
}
},
{
"term": {
"eapid": 0
}
},
{
"term": {
"departureAirport": "\"OVB\""
}
}
]
}
}
}
}
}
I don't get results back.
Mention the mapping that you used? Run GET _mapping to get that. That will help debug the issue.
But my hunch is that this is an analyzer issue. The field departureAirport must have been analyzed such that the double inverted quotes in its values got stripped off during indexing. This is the default behaviour. What I mean to say is, the field departureAirport has value "OVB" (without the quotes) indexed and not "\"OVB\"" (with the quotes). That is why you do not get results with the value having quotes.

Resources