//Kibana 查询
GET index_official_document_content/_search
{
"query": {
"bool":{
"must": [
{
"bool":{
"should": [
{
"term":{
"AllCanWatch" : true
}
},
{
"term":{
"DeptWatchAuthority" : {
"value" : 677
}
}
},
{
"term":{
"PersonWatchAuthority" : {
"value": 555
}
}
}
]
}
},
{
"nested": {
"path": "Contents",
"query": {
"bool" : {
"should": [
{
"wildcard": {
"Contents.Title.keyword": "*省市查询的条件限制*"
}
},
{
"match": {
"Contents.Content": "省市查询的条件限制"
}
},
{
"nested" :{
"path" : "Contents.FileContents",
"query": {
"bool" : {
"should":[
{
"wildcard": {
"Contents.FileContents.FileName.keyword": "*省市查询的条件限制*"
}
},
{
"match": {
"Contents.FileContents.ContentText": "省市查询的条件限制"
}
}
]
}
}
}
}
]
}
}
}
}
]
}
}
}
should.Add(n =>
n.Nested(ne =>
ne.Path(p => p.Contents)
.Query(qq =>
qq.Bool(bb =>
bb.Should(x =>
x.Wildcard(t => t.Field(f => f.Contents.Suffix("Title.keyword")).Wildcard("*" + keyWord + "*"))
)
)
)
)
);
// 文件名查询
should.Add(n =>
n.Nested(ne =>
ne.Path(p => p.Contents)
.Query(qq =>
qq.Bool(bb =>
bb.Should(x =>
x.Nested(xn => xn.Path(xnp => xnp.Suffix("Contents.FileContents"))
.Query(xnpq =>
xnpq.Bool(xnbb =>
xnbb.Should(xnbbx =>
xnbbx.Wildcard(xnt => xnt.Field(xnf => xnf.Contents.Suffix("FileContents").Suffix("FileName.keyword")).Wildcard("*" + keyWord + "*"))
)
)
)
)
)
)
)
)
);
//内容查询
should.Add(n =>
n.Nested(ne =>
ne.Path(p => p.Contents)
.Query(qq =>
qq.Bool(bb =>
bb.Should(x =>
x.Match(t => t.Field(f => f.Contents.Suffix("Content")).Query(keyWord))
)
)
)
)
);
should.Add(n =>
n.Nested(ne =>
ne.Path(p => p.Contents)
.Query(qq =>
qq.Bool(bb =>
bb.Should(x =>
x.Nested(xn => xn.Path(xnp => xnp.Suffix("Contents.FileContents"))
.Query(xnpq =>
xnpq.Bool(xnbb =>
xnbb.Should(xnbbx =>
xnbbx.Match(xnt => xnt.Field(xnf => xnf.Contents.Suffix("FileContents").Suffix("ContentText")).Query(keyWord))
)
)
)
)
)
)
)
)
);