我正在尝试将两个字段复制到第三个字段,该字段应该具有'关键字' (因为我希望能够通过它进行聚合,而不需要执行全文搜索)
PUT /test/_mapping/_doc
{
"properties": {
"first": {
"copy_to": "full_name",
"type": "keyword"
},
"last": {
"copy_to": "full_name",
"type": "keyword"
},
"full_name": {
"type": "keyword"
}
}
}
然后我发布了一个新文件:
POST /test/_doc
{
"first": "Bar",
"last": "Foo"
}
使用复合字段full_name
查询它:
GET /test2/_search
{
"query": {
"match": {
"full_name": "Bar Foo"
}
}
}
并且没有返回命中。
如果复合字段full_name
的类型为text
,那么它按预期工作并在文档中描述:
https://www.elastic.co/guide/en/elasticsearch/reference/current/copy-to.html
是否无法复制到关键字类型字段?
答案 0 :(得分:0)
问题是您使用match
查询 - 当您为文档编制索引时,您使用的关键字类型根据ES documentation是" ...只能按其确切值进行搜索。 #34;
但是,当您查询该字段时,您使用text
查询,该查询正在使用标准分析器,除了其他内容之外,还会使用较低的套管,导致您的条款不匹配。
在这种情况下,我可以想到几个选项:
match
,这将执行与term
查询相同的分析。match
查询而不是@objc func panGesture(recognizer: UIPanGestureRecognizer) {
let window = UIApplication.shared.keyWindow
let translation = recognizer.translation(in: self)
let currentY = self.frame.minY
let partialY = (window?.frame.height)!-194
let halfWayPoint = ((window?.frame.height)!/2)-40
self.frame = CGRect(x: 0, y: currentY + translation.y, width: self.frame.width, height: self.frame.height)
recognizer.setTranslation(CGPoint.zero, in: self)
switch recognizer.state {
case .changed:
// Prevent scrolling up past y:0
if currentY <= 0
{
self.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height)
}
case .ended:
// Snap to 80 (y) (expanded)
if currentY < 80 || currentY > 80 && currentY < halfWayPoint
{
UIView.animate(withDuration:0.62, delay: 0.0, usingSpringWithDamping: 0.62, initialSpringVelocity: 0.5, options: .curveEaseInOut, animations:
{
recognizer.view!.frame = CGRect(x: 0, y: 80, width: self.frame.width, height: self.frame.height)
}, completion: { (true) in
self.isExpanded = true
})
}
// Snap back to partial (y) (original position)
if currentY > partialY || currentY < partialY && currentY > halfWayPoint
{
UIView.animate(withDuration:0.62, delay: 0.0, usingSpringWithDamping: 0.62, initialSpringVelocity: 0.5, options: .curveEaseInOut, animations:
{
recognizer.view!.frame = CGRect(x: 0, y: partialY, width: self.frame.width, height: self.frame.height)
}, completion: {(true) in
self.isExpanded = false
})
}
default:
print("Default")
}
答案 1 :(得分:0)
看来copy_to的目标字段类型必须是文本类型。