目前正在使用 elasticsearch 开发标签搜索应用程序,我为索引中的每个文档提供了一个标签数组,以下是文档外观的示例:
_source: {
title: "Keep in touch scheme",
intro: "<p>hello this is a test</p> ",
full: " <p>again this is a test mate</p>",
media: "",
link: "/training/keep-in-touch",
tags: [
"employee",
"training"
]
}
Run Code Online (Sandbox Code Playgroud)
我希望能够进行搜索并且只返回带有所有指定标签的文档。
使用上面的例子,如果我搜索带有标签的文档 ["employee", "training"]则将返回上述结果。
相反,如果我用标签搜索 ["employee", "other"],则不会返回任何内容;搜索查询中的所有标签都必须匹配。
目前我正在做:
query: {
bool: {
must: [
{ match: { tags: ["employee","training"] }}
]
}
}
Run Code Online (Sandbox Code Playgroud)
但我只是收到返回的异常,例如
IllegalStateException[Can't get text on a START_ARRAY at 1:128];
Run Code Online (Sandbox Code Playgroud)
我还尝试连接数组并使用逗号分隔的字符串,但是这似乎与第一个标签匹配的任何内容相匹配。
关于如何解决这个问题的任何建议?干杯
我无法在我的 CSS 中覆盖父级的宽度。本质上,我有一个父级和一个子级 div,例如:
.parent{ width: 768px; background-color: red; }
.child{ background-color:blue; }Run Code Online (Sandbox Code Playgroud)
<div class="parent">
<div class="child">
//content
</div>
</div>Run Code Online (Sandbox Code Playgroud)
很多元素仍然使用 768px 宽度的 parent 参数,但是我希望这个特定的子元素扩展屏幕的整个宽度 - 我尝试过 left: 0, right: 0,清除浮动并将宽度设置为汽车。如果可以,我也想避免使用 !important。
有什么建议 ?
我想要的准确表示如下所示:
_____
|par. |
_|_____|_
| child |
| |
|_________|
| |
|_____|
Run Code Online (Sandbox Code Playgroud)