Posts

Search in ElasticSearch with where condition -

let's have documents following fields: {field1, field2, costprice, sellingprice} i need run queries of conditions require difference between costprice , sellingprice in standard sql, example be: select * table1 costprice-sellingprice>0 how can achieve in elasticsearch? still scripts need: { "query": { "bool": { "must": [ { "match_all": {} } ], "filter": { "script": { "script": "doc['costprice'].value - doc['sellingprice'].value > 0" } } } } }

get element count with a few parameters angularjs -

i want filter elements using angular's filter check on 2 attributes , number of returned elements this have tried: $scope.countpriorityactive = true; $scope.getcountactive = function(strcat) { return filterfilteractive($scope.tasks, {priority: strcat, active: true}).length; }; but it's not working have started editing example: http://plnkr.co/edit/8ybrtd?p=preview what's mistake? you forgot add "active" attribute in elements of array { id: 1, name: 'iron man', fname: 'tony', lname: 'stark', location: 'stark tower', comic: 'marvel' active: true //this need add each element }, also need call "filterfilter", not "filterfilteractive" unless made new filter yourself

oop - Is there any benefit from explicitly defining all used classes and namespaces at the beggining of PHP class? -

consider these 2 classes: namespace foo\bar; use logicexception; use memcached; class baz extends memcached { public function testbaz() { throw new logicexception('not implemented'); } } the same class written as: namespace foo\bar; class baz2 extends \memcached { public function testbaz() { throw new \logicexception('not implemented'); } } is there diffrence in performance of these 2 classes? if use composer's optimized autoloading? also consider these 2 classes: namespace foo\bar; use acme\demo; class kaz { public function init(demo\unita $unita, demo\unitb $unitb) { // } } the same coded as: namespace foo\bar; use acme\demo\unita; use acme\demo\unitb; class kaz2 { public function init(unita $unita, unitb $unitb) { // } } and again same questions: there performance diffrence between two? if use composers optimized autoloading? to clarify questions: there ...

javascript - Update DOM reference in jQuery each -

i modifying elements innerhtml property inside $.each() loop. if stack of elements contains childrens of element update innerhtml , dom reference of children lost. example: $(function(){ $stack = $(".myelement, .myelement *"); $stack.each(function(){ var $this = $(this); var element = $(this)[0]; console.log(element.innerhtml = element.innerhtml + " modified"); }); }); fiddle: https://jsfiddle.net/b0ux0v5e/ what happens first modify innerhtml of .myelement . includes children p . therefore dom reference of element lost , "modified" not appended. how can such scenario solved without building function creates unique selector element , re-catches in each loop? note: not asking appending text nodes. example. in real project replacing text in innerhtml . don't modify innerhtml, destroy/recreate elements inside , force re-render. can use insertadjacenthtml or jquery's append add element. ...

go - Panic during panic -

when running http server in go (go1.2.1 linux/amd64) rare error. unexpected fault address 0xb84004 fatal error: fault [signal 0x7 code=0x2 addr=0xb84004 pc=0x421d62] goroutine 1 [running]: unexpected fault address 0xacb59c panic during panic this happened once, far, after week of running , not reproducible. however, still know means , how happen. unfortunately cannot provide code sample, since don't know might occur , code not open source (yet), i'm looking more general answer. anyone?

asp.net - File is being used by another process in c# -

i trying delete file in c#, receiving message file used process. want check if files exists , close it. using following function in order check if file open: public static bool isfileinuse(string path) { if (string.isnullorempty(path)) throw new argumentexception("'path' cannot null or empty.", "path"); try { using (var stream = new filestream(path, filemode.open, fileaccess.read)) { } } catch (ioexception) { return true; } return false; } and trying when file in use close it: bool checking = isfileinuse(file ); file.create(file ).close(); if (file.exists(file)) { file.delete(file ); } i got issues in file.create line, receiving message: file being used process. edit: trying use lock approach in order delete file. suppose delete file inside lock statement? how can use lock statement? why suppose reading operation fail...

symfony - Symfony2: Dynamically generate URL protocol (HTTP/HTTPS) -

i know many ways of forcing route or whole section use either http or https: http://symfony.com/doc/current/cookbook/routing/scheme.html http://symfony.com/doc/current/cookbook/security/force_https.html how let symfony 2 adopt protocol scheme (http vs https) ...my question is: there way decided dynamically? by this, mean, when generate url {{url('route_name'}} generates url using same protocol current page using. http://domain/index links to http://domain/route https://domain/index links to https://domain/route