我正在研究概念验证代码,以根据提供给我正在编写的高度特定的搜索Web服务的关键字动态生成CAML.我没有使用SharePoint提供的搜索Web服务来进行此证明.我已经为我想要实现的目标做了这样的事情.从我的所有研究中,我找不到我想要实现的一个接近的例子,即检查多个值的多个字段.是的,我已经看过SO了我的答案,包括这个:需要帮助建立CAML查询.
话虽如此,如果有可能,如何在CAML中编写以下类似SQL的查询?
SELECT FirstName, LastName, Description, Profile
FROM SomeFakeTable
WHERE (FirstName = 'John' OR LastName = 'John' OR Description = 'John' OR Profile='John')
AND (FirstName = 'Doe' OR LastName = 'Doe' OR Description = 'Doe' OR Profile='Doe')
AND (FirstName = '123' OR LastName = '123' OR Description = '123' OR Profile='123')
Run Code Online (Sandbox Code Playgroud) 虽然是Lucene逻辑结构,但我试图在我们的内容中出现一些搜索结果时突出显示我的嵌套字段.
以下是Elasticsearch文档的解释(映射嵌套类型 `)
内部实施
在内部,嵌套对象被索引为附加文档,但是,由于可以保证它们在同一"块"中被索引,因此可以非常快速地与父文档连接.
在对索引执行操作时会自动屏蔽这些内部嵌套文档(例如使用match_all查询进行搜索),并且在使用嵌套查询时它们会冒泡.
由于嵌套文档始终屏蔽到父文档,因此永远不能在嵌套查询的范围之外访问嵌套文档.例如,可以在嵌套对象内的字段上启用存储字段,但无法检索它们,因为存储字段是在嵌套查询范围之外获取的.
我有一个Elasticsearch索引,其中包含如下映射:
{
"my_documents": {
"dynamic_date_formats": [
"dd.MM.yyyy",
"yyyy-MM-dd",
"yyyy-MM-dd HH:mm:ss"
],
"index_analyzer": "Analyzer2_index",
"search_analyzer": "Analyzer2_search_decompound",
"_timestamp": {
"enabled": true
},
"properties": {
"identifier": {
"type": "string"
},
"description": {
"type": "multi_field",
"fields": {
"sort": {
"type": "string",
"index": "not_analyzed"
},
"description": {
"type": "string"
}
}
},
"files": {
"type": "nested",
"include_in_root": true,
"properties": {
"content": {
"type": "string",
"include_in_root": true …Run Code Online (Sandbox Code Playgroud) 使用Sequelize版本实现:"^ 4.15.0"
我试图从包括协会的2级添加where条件.
Model1.find({
include: [
{
model: Model2,
as: 'model2_alias',
attributes: [
'model2_id'
],
include: [{
model: Model3,
as: 'model3_alias',
attributes: [
'model3_id'
]
}]
}
],
where: {
model3_alias.id: { [Op.in]: [1, 2, 3] }
}
});
Run Code Online (Sandbox Code Playgroud)
我累了这个方法:
where: {
'$model2_alias.model3_alias.id$': { [Op.in]: [1, 2, 3] }
}
Run Code Online (Sandbox Code Playgroud)
但是给出了model2_alias.model3_alias.id未定义/未找到的错误.
上面的内容确实有效,因为'$model2_alias.id$': { [Op.in]: [1, 2, 3] }语法必须写入,但如何进一步降低级别.
在任何MySQL管理工具中执行形成的SQL语句时,会给出正确的结果,因此where我尝试实现的条件也没有错.
我在这里缺少的任何想法或仅适用于一个级别.然后该怎么做更多级别?
我想使用where方法为以下内容编写查询
SELECT * FROM videos
WHERE 'privacy' = 'public' OR
(privacy = 'private' AND
id IN (SELECT vid
FROM vid_ads
WHERE 'aid'=#{current_id}))
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下查询但最终出现语法错误
Video.where("privacy = 'public' OR
(privacy = 'private' AND id = ?)",
VidAd.where(:aid => current_id).select("vid"))
Run Code Online (Sandbox Code Playgroud)
请帮忙
假设我想找出谁写CLRS了一本书 db (tables BOOK, AUTHORwith ajunction table BOOK_AUTHOR)。
SelectConditionStep<Record1<String>> query = create
.select(AUTHOR.LASTNAME.as("AuthorName"))
.from(
(
BOOK.leftOuterJoin(BOOK_AUTHOR).on(BOOK.ID.eq(BOOK_AUTHOR.BOOKID))
).leftOuterJoin(AUTHOR).on(AUTHOR.ID.eq(BOOK_AUTHOR.AUTHORID))
)
.where(BOOK.TITLE.eq(CLRS_title))
;
Run Code Online (Sandbox Code Playgroud)
匹配整个表格有点低效,只是选择一本书。我现在想在比赛前选择那本书。
关于这个问题的 jOOQ 文档让我相信这可能看起来像这样:
Table<Record1<Integer>> clrs = create
.select(BOOK.ID.as("bookID"))
.from(BOOK)
.where(BOOK.TITLE.eq(CLRS_title))
.asTable()
;
SelectJoinStep<Record1<String>> query = create
.select(AUTHOR.LASTNAME.as("AuthorName"))
.from(
(
clrs.leftOuterJoin(BOOK_AUTHOR).on(clrs.field("bookID").eq(BOOK_AUTHOR.BOOKID))
).leftOuterJoin(AUTHOR).on(AUTHOR.ID.eq(BOOK_AUTHOR.AUTHORID))
)
;
Run Code Online (Sandbox Code Playgroud)
但是,这无法编译,因为
Cannot resolve method 'eq(org.jooq.TableField<ch.cypherk.bookdb.public_.tables.records.BookAuthorRecord,java.lang.Integer>)'
Run Code Online (Sandbox Code Playgroud)
在加入条件下。
编写此连接的正确方法是什么?
在以下JSON中,我想选择销售额> 12500的记录.如何在ReThinkDB和ReQL中执行此操作?
JSON是:
{
"address": {
"address_line1": "Address Line 1" ,
"address_line2": "Address Line 2" ,
"city": "Kochin" ,
"country": "India" ,
"state": "Kerala"
} ,
"id": "bbe6a9c4-ad9d-4a69-9743-d5aff115b280" ,
"name": "Dealer 1" ,
"products": [
{
"product_name": "Stabilizer" ,
"sales": 12000
} ,
{
"product_name": "Induction Cooker" ,
"sales": 14000
}
]
}, {
"address": {
"address_line1": "Address Line 1" ,
"address_line2": "Address Line 2" ,
"city": "Kochin" ,
"country": "India" ,
"state": "Kerala"
} ,
"id": "f033a4c2-959c-4e2f-a07d-d1a688100ed7" ,
"name": …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Java进行一种嵌套Neo4j查询,该查询首先标记节点的子集,然后尝试匹配其中的某些模式。更具体地说,这就像合并2个此类查询:
1-匹配(n)-[r:RELATIONSHIP * 1..3]->(m)设置m:LABEL
2-匹配(p:LABEL)-[r2:RELATIONSHIP]->(q:OTHERLABEL),其中r2.time <100返回p,r2,q
有没有一种方法可以使用Java函数engine.execute()将两个查询合并为一个?
这是我想要的SQL(ClearinghouseKey是bigint):
select *
from ConsOutput O
where O.ClearinghouseKey IN (
select distinct P.clearinghouseKey
from Project P
Inner join LandUseInProject L on L.ClearinghouseKey = P.ClearinghouseKey
where P.ProjectLocationKey IN ('L101', 'L102', 'L103')
and L.LandUseKey IN ('U000', 'U001', 'U002', 'U003')
)
Run Code Online (Sandbox Code Playgroud)
内部查询是直接的,并在LINQPad中给出正确的结果:
var innerQuery = (from p in Projects
join l in LandUseInProjects on p.ClearinghouseKey equals l.ClearinghouseKey
where locations.Contains(p.ProjectLocationKey)
&& (landuses.Contains(l.LandUseKey))
select new { p.ClearinghouseKey }).Distinct();
Run Code Online (Sandbox Code Playgroud)
但是外部查询给出了错误:从...中键入参数包含..无法从用法推断:
var returnQuery = from o in OperOutput
where (innerQuery).Contains(o.ClearinghouseKey)
select o;
Run Code Online (Sandbox Code Playgroud)
是因为ClearinghouseKey是一个bigint?还有其他任何方式来编写此查询吗? …
我有一个像这样的查询(不,我的表和字段不是由这些名称调用,但结构是相同的) -
SELECT table1.id, table2.id, table1.phone1
FROM table1 LEFT OUTER JOIN
table3 ON table3.id = table1.id LEFT OUTER JOIN
table2 ON table3.id2 = table2.id
WHERE table1.phone1 IS NOT NULL AND LTRIM(RTRIM(table1.phone1)) <> ''
UNION
SELECT table1.id, table2.id, table1.phone2
FROM table1 LEFT OUTER JOIN
table3 ON table3.id = table1.id LEFT OUTER JOIN
table2 ON table3.id2 = table2.id
WHERE table1.phone2 IS NOT NULL AND LTRIM(RTRIM(table1.phone2)) <> ''
UNION
SELECT table1.id, table2.id, table2.phone
FROM table1 LEFT OUTER JOIN
table3 ON table3.id = table1.id …Run Code Online (Sandbox Code Playgroud) 我必须在table现有client_id列中插入一些数据,所以我使用 select 和 insert
INSERT into 'my_table' (column1, client_id, column3) VALUES (val1,select distinct client_id from 'my_table', val3)
我需要来自同一个表的my_tableclient_id 并且我需要在插入语句中使用 client_ids。
SELECT DISTINCT client_id FROM my_table 给了我 113 个 client_id,所以我想使用上述方法为每个 113 个客户端插入一些行。
我做了这个查询
INSERT INTO client_notification_preferences (client_id, object_type , frequency,created_at,updated_at) SELECT DISTINCT client_id, 'ClientShipment',1, CURRENT_TIMESTAMP , CURRENT_TIMESTAMP FROM client_notification_preferences;
create_table "client_notification_preferences", id: :uuid, default: "uuid_generate_v4()", force: :cascade do |t|
t.uuid "client_id"
t.string "object_type"
t.integer "frequency"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
Run Code Online (Sandbox Code Playgroud)
结尾
nested-query ×10
java ×2
select ×2
sql ×2
associations ×1
biginteger ×1
caml ×1
contains ×1
filter ×1
insert ×1
jooq ×1
json ×1
linq ×1
lucene ×1
mysql ×1
neo4j ×1
nested ×1
node.js ×1
postgresql ×1
reql ×1
rethinkdb ×1
sequelize.js ×1
sharepoint ×1
where-clause ×1
where-in ×1