我想在文档中添加一个应该可以搜索的字段,但是当我们进行获取/搜索时,它不应该出现在 _source 下。
我已经尝试过索引和存储选项,但无法通过它实现。它更像 _all 或 copy_to,但在我的情况下,值是由我提供的(不是从文档的其他字段中收集的。)
我正在寻找可以实现以下情况的映射。
当我放文件时:
PUT my_index/_doc/1
{
"title": "Some short title",
"date": "2015-01-01",
"content": "A very long content field..."
}
并进行搜索
获取 my_index/_search
输出应该是
{
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [
{
"_index" : "my_index",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"title" : "Some short title",
"date" : "2015-01-01"
}
}
]
}
}
当我进行以下搜索时
GET my_index/_search
{
"query": {
"query_string": {
"default_field": "content",
"query": "long content"
}
}
}
它应该导致我
"hits" : {
"total" : 1,
"max_score" : 0.5753642,
"hits" : [
{
"_index" : "my_index",
"_type" : "_doc",
"_id" : "1",
"_score" : 0.5753642,
"_source" : {
"title" : "Some short title",
"date" : "2015-01-01"
}
}
]
}