我想构建一个与该属性完全匹配的查询,并接受多个值来搜索该属性。
目前我正在使用以下查询来获取单个文档的数据。
query = {
"match_phrase" : {
"id" : "abc"
}
};
我想根据id属性匹配多个值。像
这样的东西query = {
"match_phrase" : {
"id" : ["abc", "xyz"]
}
};
我想知道什么是相同的上述查询。
{
"abc " : {
"mappings " : {
"keywordsearches " : {
"properties " : {
"keyword " : {
"type " : "string "
},
"module_name " : {
"type " : "string "
},
"timestamp " : {
"type " : "date ",
"format " : "dateOptionalTime "
}
}
},
"npmmodules " : {
"properties " : {
"author " : {
"type " : "string "
},
"contributors " : {
"type " : "string "
},
"created_at " : {
"type " : "date ",
"format " : "dateOptionalTime "
},
"curatedcontents " : {
"properties " : {
"description " : {
"type " : "string "
},
"link " : {
"type " : "string "
}
}
},
"curatedcontents_count " : {
"type " : "long "
},
"datachanged " : {
"type " : "boolean "
},
"dependencies " : {
"properties " : {
"name " : {
"type " : "string "
},
"version " : {
"type " : "string "
}
}
},
"description " : {
"type " : "string "
},
"downloads " : {
"properties " : {
"count " : {
"type " : "long "
},
"day " : {
"type " : "date ",
"format " : "dateOptionalTime "
}
}
},
"downloads_meta " : {
"properties " : {
"last_updated " : {
"type " : "date ",
"format " : "dateOptionalTime "
}
}
},
"fork " : {
"type " : "boolean "
},
"full_name " : {
"type " : "string "
},
"gh_meta " : {
"properties " : {
"blacklist " : {
"properties " : {
"repo " : {
"type " : "string "
},
"user " : {
"type " : "string "
}
}
},
"etag " : {
"type " : "string "
},
"last-modified " : {
"type " : "string "
}
}
},
"git_url " : {
"type " : "string "
},
"homepage " : {
"type " : "string "
},
"html_url " : {
"type " : "string "
},
"id " : {
"type " : "string "
},
"keywords " : {
"type " : "string "
},
"latest " : {
"type " : "string "
},
"licenses " : {
"properties " : {
"MIT " : {
"type " : "string "
},
"covers " : {
"type " : "string "
},
"description " : {
"type " : "string "
},
"file " : {
"type " : "string "
},
"license " : {
"type " : "string "
},
"link " : {
"type " : "string "
},
"name " : {
"type " : "string "
},
"type " : {
"type " : "string "
},
"type: " : {
"type " : "string "
},
"ur " : {
"type " : "string "
},
"url " : {
"type " : "string "
},
"version " : {
"type " : "string "
}
}
},
"maintainers " : {
"type " : "string "
},
"name " : {
"type " : "string "
},
"npm_meta " : {
"properties " : {
"etag " : {
"type " : "string "
},
"last-modified " : {
"type " : "date ",
"format " : "dateOptionalTime "
}
}
},
"npm_stars " : {
"type " : "long "
},
"open_issues_count " : {
"type " : "long "
},
"pushed_at " : {
"type " : "date ",
"format " : "dateOptionalTime "
},
"rank " : {
"type " : "double "
},
"readme " : {
"type " : "string "
},
"releases " : {
"properties " : {
"time " : {
"type " : "date ",
"format " : "dateOptionalTime "
},
"version " : {
"type " : "string "
}
}
},
"repository " : {
"properties " : {
"author " : {
"type " : "string "
},
"bugs " : {
"type " : "string "
},
"commit_date " : {
"type " : "date ",
"format " : "dateOptionalTime "
},
"description " : {
"type " : "string "
},
"dist " : {
"type " : "string "
},
"git " : {
"type " : "string "
},
"github " : {
"type " : "string "
},
"handle " : {
"type " : "string "
},
"homepage " : {
"type " : "string "
},
"id_string " : {
"type " : "string "
},
"job " : {
"type " : "string "
},
"main " : {
"type " : "string "
},
"path " : {
"type " : "string "
},
"private " : {
"type " : "string "
},
"repository " : {
"type " : "string "
},
"revision " : {
"type " : "string "
},
"static " : {
"type " : "string "
},
"title " : {
"type " : "string "
},
"tyep " : {
"type " : "string "
},
"typ " : {
"type " : "string "
},
"type " : {
"type " : "string "
},
"type: " : {
"type " : "string "
},
"update " : {
"type " : "string "
},
"ur " : {
"type " : "string "
},
"url " : {
"type " : "string "
},
"web " : {
"type " : "string "
},
"web " : {
"type " : "string "
}
}
},
"rev " : {
"type " : "string "
},
"stargazers_count " : {
"type " : "long "
},
"subscribers_count " : {
"type " : "long "
},
"updated_at " : {
"type " : "date ",
"format " : "dateOptionalTime "
},
"userreviews " : {
"properties " : {
"review " : {
"type " : "string "
},
"timestamp " : {
"type " : "date ",
"format " : "dateOptionalTime "
}
}
},
"version " : {
"type " : "string "
},
"watchers_count " : {
"type " : "long "
}
}
},
"npmusers " : {
"properties " : {
"blog " : {
"type " : "string "
},
"created_at " : {
"type " : "date ",
"format " : "dateOptionalTime "
},
"email " : {
"type " : "string "
},
"followers " : {
"type " : "long "
},
"following " : {
"type " : "long "
},
"gh_meta " : {
"properties " : {
"blacklist " : {
"properties " : {
"user " : {
"type " : "string "
}
}
},
"etag " : {
"type " : "string "
},
"last-modified " : {
"type " : "string "
}
}
},
"github " : {
"type " : "string "
},
"html_url " : {
"type " : "string "
},
"id " : {
"type " : "string "
},
"name " : {
"type " : "string "
},
"npm_meta " : {
"properties " : {
"etag " : {
"type " : "string "
},
"last-updated " : {
"type " : "date ",
"format " : "dateOptionalTime "
}
}
},
"public_gists " : {
"type " : "long "
},
"public_repos " : {
"type " : "long "
},
"type " : {
"type " : "string "
},
"updated_at " : {
"type " : "date ",
"format " : "dateOptionalTime "
}
}
}
}
}
}
答案 0 :(得分:0)
您可以使用布尔查询。
{
"bool" : {
"should" : [
{"match_phrase" : {"id" : "abc" }},
{"match_phrase" : {"id" : "xyz" }}
],
"minimum_should_match" : 1
}
}
答案 1 :(得分:0)
使用条款查询:
{
"query": {
"terms": {
"id": [
"abc",
"xyz"
]
}
}
}
它有帮助!
答案 2 :(得分:0)
最后,我最终使用了mget,它为文档中的任何属性提供了完全匹配
{
"index" : "index",
"type" : "type",
"body" : {
"attribute_name" : "attribute_value"
}
}