exists

Best way to check if a field exist in an Elasticsearch document

╄→гoц情女王★ 提交于 2019-11-29 01:03:13
May be is a very stupid question, What is the best way to check if a field of a document in elasticsearch exists? I can't find anything in the documentation. For example if this document doesn't have the field/key "price" I don't want to return in the result. { "updated": "2015/09/17 11:27:27", "name": "Eye Shadow", "format": "1.5 g / 0.05 oz", } What I can do? Thanks You can use the exists filter combined with a bool/must filter like this: { "query": { "filtered": { "filter": { "bool": { "must": [ { "exists": { "field": "price" } }, ... <-- your other constraints, if any ] } } } } }

08数据库复习02

落花浮王杯 提交于 2019-11-29 00:32:39
1.数据的操作 -- 更新名字为4为的用户,让其年龄+100 UPDATE cms_user SET age = age + 100 WHERE username LIKE '____'; -- 更新前三条记录,让已有年龄+20 UPDATE cms_user SET age = age + 20 LIMIT 3; 注意:不能使用偏移量的分页限制方式。 -- 删除用户性别为男的用户,按照年龄降序排列,删除前2条记录 DELETE FROM cms_user WHERE sex = '男' ORDER BY age DESC LIMIT 2; 2.连接查询 -- 查询cms_user id,username -- provinces,proName SELECT cms_user.id,cms_user.username,provinces.proName FROM cms_user,provinces;-- 这样得到的结果是一个笛卡尔积的形式 SELECT cms_user.id,cms_user.username,provinces.proName FROM cms_user,provinces WHERE cms_user.proId = provinces.`id`; -- 内连接的方式进行查询 SELECT u.`id`,u.`username`,p.`proName`

SQL: Return “true” if list of records exists?

我怕爱的太早我们不能终老 提交于 2019-11-28 23:43:24
问题 An alternative title might be: Check for existence of multiple rows? Using a combination of SQL and C# I want a method to return true if all products in a list exist in a table. If it can be done all in SQL that would be preferable. I have written a method that returns whether a single productID exists using the following SQL: SELECT productID FROM Products WHERE ProductID = @productID If this returns a row, then the c# method returns true, false otherwise. Now I'm wondering if I have a list

Select columnValue if the column exists otherwise null

◇◆丶佛笑我妖孽 提交于 2019-11-28 23:39:28
问题 I'm wondering if I can select the value of a column if the column exists and just select null otherwise. In other words I'd like to "lift" the select statement to handle the case when the column doesn't exist. SELECT uniqueId , columnTwo , /*WHEN columnThree exists THEN columnThree ELSE NULL END*/ AS columnThree FROM (subQuery) s Note, I'm in the middle to solidifying my data model and design. I hope to exclude this logic in the coming weeks, but I'd really like to move beyond this problem

C# Cannot check Session exists?

前提是你 提交于 2019-11-28 21:24:24
I get an error when I do the following: if(Session["value"] != null) { // code } The error i get is this: Object reference not set to an instance of an object. Why is this? I always check my session this way? I am using the MVC Framework, does this has something to do with it? EDIT: The code is in the constructor of a Controller: public class MyController : ControllerBase { private int mVar; public MyController() { if (Session["value"] != null) { mVar= (int)Session["value"]; } } } The session only really exists during the processing of an action - I wouldn't expect it to be valid in the

Syntax error with IF EXISTS UPDATE ELSE INSERT

﹥>﹥吖頭↗ 提交于 2019-11-28 20:56:11
I'm using MySQL 5.1 hosted at my ISP. This is my query mysql_query(" IF EXISTS(SELECT * FROM licensing_active WHERE title_1='$title_1') THEN BEGIN UPDATE licensing_active SET time='$time' WHERE title_1='$title_1') END ELSE BEGIN INSERT INTO licensing_active(title_1) VALUES('$title_1') END ") or die(mysql_error()); The error is ... check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF EXISTS(SELECT * FROM licensing_active WHERE title_1='Title1') THEN ' at line 1 My actual task involves WHERE title_1='$title_1' AND title_2='$title_2' AND version='

How to exclude records with certain values in sql select

自古美人都是妖i 提交于 2019-11-28 20:38:29
How do I only select the stores that don't have client 5 ? StoreId ClientId ------- --------- 1 4 1 5 2 5 2 6 2 7 3 8 I'm trying something like this: SELECT SC.StoreId FROM StoreClients INNER JOIN StoreClients SC ON StoreClients.StoreId = SC.StoreId WHERE SC.ClientId = 5 GROUP BY StoreClients.StoreId That seems to get me all the stores that have that client but I can't do the opposite because if I do <> 5 ill still get Store 1 and 2 which I don't want. I'm basically trying to use this result in another query's EXISTS IN clause One way: SELECT DISTINCT sc.StoreId FROM StoreClients sc WHERE NOT

is_file or file_exists in PHP

旧时模样 提交于 2019-11-28 19:24:58
问题 I need to check if a file is on HDD at a specified location ($path.$file_name). Which is the difference between is_file() and file_exists() functions and which is better/faster to use in PHP? 回答1: is_file() will return false if the given path points to a directory. file_exists() will return true if the given path points to a valid file or directory. So it would depend entirely on your needs. If you want to know specifically if it's a file or not, use is_file() . Otherwise, use file_exists() .

Is EXISTS more efficient than COUNT(*)>0?

二次信任 提交于 2019-11-28 19:13:32
I'm using MySQL 5.1, and I have a query that's roughly of the form: select count(*) from mytable where a = "foo" and b = "bar"; In my program, the only thing that it checks is whether this is zero or nonzero. If I convert this into: select exists(select * from mytable where a = "foo" and b = "bar"); is MySQL smart enough to stop searching when it hits the first one? Or is there some other way to communicate to MySQL that my intent is simply to find out if any records match this, and I don't need an exact count? Yes, MySQL (indeed all database systems as far as I'm aware) will stop processing

How can you check to see if a file exists (on the remote server) in Capistrano?

只愿长相守 提交于 2019-11-28 18:29:18
问题 Like many others I've seen in the Googleverse, I fell victim to the File.exists? trap, which of course checks your local file system, not the server you are deploying to. I found one result that used a shell hack like: if [[ -d #{shared_path}/images ]]; then ... but that doesn't sit well with me, unless it were wrapped nicely in a Ruby method. Has anybody solved this elegantly? 回答1: @knocte is correct that capture is problematic because normally everyone targets deployments to more than one