Posts

elasticsearch - How to handle wildcards in elastic search structured queries -

my use case requires query our elastic search domain trailing wildcards. wanted opinion on best practices of handling such wildcards in queries. do think adding following clauses practice queries: "query" : { "query_string" : { "query" : "attribute:postfix*", "analyze_wildcard" : true, "allow_leading_wildcard" : false, "use_dis_max" : false } } i've disallowed leading wildcards since heavy operation. wanted how analyzing wildcard every query request in long run. understanding is, analyze wildcard have no impact if query doesn't have wildcards. correct? if have possibility of changing mapping type , index settings, right way go create custom analyzer edge-n-gram token filter index prefixes of attribute field. curl -xput http://localhost:9200/your_index -d '{ "settings": { "analysis": { "filt...

ruby - Watir-webdriver throws 'not clickable' error even when element is visible, present -

i trying automate tests in ruby using latest watir-webdriver 0.9.1, selenium-webdriver 2.53.0 , chrome extension 2.21. website testing has static headers @ top or static footers @ bottom. hence since watir auto-scrolls element view before clicking, elements hidden under static header or static footer. not want set desired_capabitlites (elementscrollbehavior) 1 or 0 websites testing can have both - static header or static footer or both. hence question 1) why watir throw exception 'element not clickable' when element visible , present? see ruby code ( have picked random company website example) , results below. 2) how can resolve without resorting elementscrollbehaviour? ruby code: require 'watir-webdriver' browser = watir::browser.new :chrome begin # step 1 browser.goto "shop.coles.com.au/online/mobile/national" # step 2 - click on 'full website' link @ bottom link = browser.link(text: "full website") #check if lin...

python - Apply function to 2D numpy array elements -

i've seen post , want similar, not same. i implementing little game of life game , using numpy arrays representing states of game. need check, how many alive neighbors cell has. got function getting window of neighbors given coordinate , row count , column count window size want have. so windows of 3x3 size this: t = true f = false [[t,t,t], [f,t,t], [f,f,f]] # random truth values in representation true stands cell being alive. wrote code iterating on cells of state, counting true values , on using double loop, think there better numpy solution. what i'd in naive approach: iterate on cells of state (not window) (i'd formulate code to executed if cell meets criteria or (being alive , surviving or being dead , coming alive)) get window (wrapping or not wrapping) (function have) check if current cell alive (could lookup in state's numpy array) if alive start alive neighbors count of -1 otherwise start 0 count true values of window ( np.sum )...

ruby on rails - Backing up and restoring Redis on Heroku -

i'm running app on heroku uses redis , postgres. occasionally backup , restore postgres lower tier staging or development testing. is there similar inbuilt redis tool backup production instance , restore local instance? write loops through each key , outputs file, , else locally reads file , restores, feel might overkill if utility exists that. thanks! redis can dump date disk file using format called rdb. should check redis provider how generate , obtain these files.

ruby - Hash of hashes from an array -

from array: this = [1, 2, 3, 4, 5] i trying create hash of hashes: {{num: 1}, {num: 2}, {num: 3}, {num: 4}, {num: 5}} but i'm getting empty hash: hash.new(this.each |num| hash.new(num: num) end) # => {} what doing wrong? first, desired result in question doesn't make sense since you're using hash {} syntax, there no keys. seems though want result array of hashes. second, you're confusing each map . each iterates through array, passing each item block. return value of arr.each arr . map , on other hand, returns new array based on return value of block: [1, 2, 3, 4, 5].map { |item| { num: item } }

linux - How to determine if sym link exists -

i'm trying determine if symbolic link exists. thought -l or -f it, doesn't seem working. vhost="/etc/apache2/sites-available/vhost.local"; if [ ! -l vhost ]; ln -s /home/user/ubuntu\ one/htdocs/vhosts/vhost.local vhost; a2ensite vhost.local; echo " -vhost.local": fi it should create sym link if there isn't one.... according test(1) manpage: -h file file exists , symbolic link (same -l) -l file file exists , symbolic link (same -h) -h or -l should trick. however, not testing against variable $vhost literal vhost . that's error. so, suppose meant say: if [ ! -l "$vhost" ]; ... additionally you're forgetting $ in ln -s : ln -s /home/user/ubuntu\ one/htdocs/vhosts/vhost.local "$vhost";

How to get country code (not ISO code) in Qt -

i'm developing application windows. find way country code 1(usa) , 82(south korea). qt provides qlocale::country enum includes countries. can use countrytostring static method in order name of each country.