Posts

Update (merge document) Elasticsearch 5.0 -

i have document update in elastic bulk. in document have field dictionary , list . how merge them? also need update query. for example: source of document index: { "simple_field": "", "dict_field": { "key": "value" }, "complex_field": { "list_field": ["value"], "dict_field1": { "list_field2": [ { "key": "val", "key1": "val2", "key2": "val" } ] } } } partial doc update: { "dict_field": { "key2":"value" } "complex_field": { "list_field": [ "value2" ], "dict_field1": { "list_field2": [ { ...

recursion - Nearest record with recursive SQL Server CTE and stepped STDistance -

when improving closest spatial match performance (geography stdistance) in sql server 2012, have found iteratively stepping search radius increases performance on our datasets. i have below 3 step query trying turn recursive cte max depth 3, distance comparison [level]*500. select n.workid, m.workid matchworkid, n.location.stdistance(m.location) meters #matchwork500 newwork n cross apply (select top (1) c.workid, c.location currwork c n.location.stdistance(c.location) <= 500 order n.location.stdistance(c.location)) m select n.workid, m.workid matchworkid, n.location.stdistance(m.location) meters #matchwork1000 newwork n left join #matchwork500 m500 on m500.workid = n.workid cross apply (select top (1) c.workid, c.location currwork c n.location.stdistance(c.location) <= 1000 order n.location.stdistance(c.lo...

c# - How to use while(datareader.Read()) -

the following code throws exception after shows message box in if-else statement. exception says reader can't read, because closed: try { using (mysqlconnection conn = new mysqlconnection(config.connectionstring())) { conn.open(); mysqlcommand cmd = new mysqlcommand("select * tb_useraccounts;", conn); mysqldatareader dr = cmd.executereader(); while (dr.read()) { if (username == (dr["username"].tostring()) && password == (dr["password"].tostring())) { frmmain main = new frmmain(); main.show(); login.hide(); } else if (username == string.empty || password == string.empty) { messagebox.show("please fill blank spaces!"); } else { messagebox.show("the username , password inserted incorrect!"); ...

dataframe - R - Efficiency for calculating a column in a data frame -

i have couple of columns in data frame times. i'm trying calculate difference in times in new column, need reset 0 every time encounter start of new pattern. please see sample data below. seq atime rt 0 18:33:00 0 20 18:48:00 15 43 19:01:00 13 56 19:47:00 24 0 21:33:00 0 9 21:45:00 12 22 21:55:00 10 45 22:13:00 18 0 06:33:00 0 22 06:47:00 14 45 06:59:00 12 62 07:22:00 23 85 07:48:00 26 i'm using following script estimate delta column. seq column increasing each 'pattern'. in sample each pattern's seq starts 0, may not case always. dat_4$rt <- 0 (i in 1:(nrow(dat_4$seq)-1)) { if (dat_4$seq[i+1] > dat_4$seq[i]) { dat_4$rt[i+1] = (chron(times=dat_4$atime[i+1]) - chron(times=dat_4$atime[i]))*1440 } else { dat_4$rt[i+1] = 0 } } although works, it's not @ efficient. 'dat_4' dataframe have 4 million records , takes 2.5 minutes process step. user system elapsed ...

java - What is a NumberFormatException and how can I fix it? -

error message: exception in thread "main" java.lang.numberformatexception: input string: "ace of clubs" @ java.lang.numberformatexception.forinputstring(numberformatexception.java:65) @ java.lang.integer.parseint(integer.java:580) @ java.lang.integer.parseint(integer.java:615) @ set07102.cards.main(cards.java:68) c:\users\qasim\appdata\local\netbeans\cache\8.1\executor-snippets\run.xml:53: java returned: 1 build failed (total time: 0 seconds) my while loop: while (response != 'q' && index < 52) { system.out.println(cards[index]); int first_value = integer.parseint(cards[index]); int value = 0; //add scanner scanner scanner = new scanner(system.in); system.out.println("will next card higher or lower?, press q if want quit"); string guess = scanner.nextline(); if(cards[index].startswith("ace")) { value = 1; } if(cards[index].startswith("2")) { value = 2; } ...

Pasting my Sumproduct formula from Excel 2016 to Excel 2007 doesn't work -

i have been working on formula using sumproduct values based on 3 criteria: date, yes or no, , types. here example: image of excel sheet table the formula used is: =sumproduct(([example1.xlsx]input!$a$3:$a$12=$a2)*([example1.xlsx]input!$b$1:$c$1=b$1)*([example1.xlsx]input!$b$2:$c$2="yes")*([example1.xlsx]input!$b$3:$c$12)) this formula in excel 2016 give me this: {0, 0, 10, 0, 0, 0, 10, 0, 0, 20}. however, when paste code excel 2007, #na. know why getting result? use sumproduct function , keep format of code because planning apply excel project. thank you wiki

c# - Dynamic query expression builder -

hi wondering how can achieve query expression below in dynamic way : datatable _datasourcematrix = getmanager.budget.getall().converttodatatable(); switch (entitytype) { case domaintype.department: datatable _departmentlist = getmanager.departmentmanager.getall().converttodatatable(); var _genericbudgetjoindepartmentlist = in _datasourcematrix.asenumerable() join b in _departmentlist.asenumerable() on a.field<int>("entityid") equals b.field<int>("departmentid") select new { entityname = b.field<string>("name"), period = a.field<string>("period"), value = a.field<double>("value"), entityid = a.field<int>("entityid") }; _datasourcematrix = _genericbudgetjoindepartmentlist.orderby(x => x.period).converttodatatable();...