我想在Elastic Search 5.0中获取存在多种类型(type1 AND type2 AND type3 ...)的文档。我知道可以通过使用URL中的type1,type2之类的多种类型并过滤_type字段来跨多种类型进行搜索。但是所有这些条件都是OR(类型1或类型2)。如何达到AND条件?
这里是我的ES中的两个文档,
{
"_index":"cust_58e8700034fa4e368590fb1396e2641c",
"_type":"unique-fp-domains",
"_id":"n_d4dbba7309a94503b25eca735078f17c_258b3ad1a11aba282f35908662bdc5432d68fd96bf3ca90013dcdd5764331399",
"_version":2,
"_score":1,
"_source":{
"mg_timestamp":1579866709096,
"violated-directive":"connect-src",
"fp-hash":"258b3ad1a11aba282f35908662bdc5432d68fd96bf3ca90013dcdd5764331399",
"time":1579866709096,
"scan-id":"n_d4dbba7309a94503b25eca735078f17c",
"blocked-uri":"play.sundaysky.com"
}
}
{
"_index":"cust_58e8700034fa4e368590fb1396e2641c",
"_type":"tag-alexa-top1k-using-csp-tld-domain",
"_id":"AW_XY4P4kmprPQ28bTUb",
"_version":1,
"_score":1,
"_source":{
"tagged-domain":"sundaysky.com",
"tag-guidance":"FP",
"additional-tag-metadata-isbase64-encoded":"eyJ0b3RhbC1hbGV4YS1tYXRjaGVzIjoyMzh9",
"project-id":2,
"fp-hash":"258b3ad1a11aba282f35908662bdc5432d68fd96bf3ca90013dcdd5764331399",
"scan-id":"n_d4dbba7309a94503b25eca735078f17c",
}
}
我想用"scan-id":"n_d4dbba7309a94503b25eca735078f17c"
从给定的两种类型的相同索引中获取文档>
我尝试过这个,
{ "size": 100, "query": { "bool": { "must": [ { "bool": { "filter": [ { "term": { "_type": { "value": "tag-alexa-top1k-using-csp-tld-domain" } } }, { "term": { "scan-id": { "value": "n_d4dbba7309a94503b25eca735078f17c" } } } ] } }, { "bool": { "filter": [ { "term": { "_type": { "value": "unique-fp-domains" } } }, { "term": { "scan-id": { "value": "n_d4dbba7309a94503b25eca735078f17c" } } } ] } } ] } } }
但是它不起作用。
我想在Elastic Search 5.0中获取存在多种类型(type1 AND type2 AND type3 ...)的文档。我知道可以通过使用多种类型(例如type1,type2 ...
您可以使用msearch。这可以组合多个搜索。您可以在他们的文档中找到关于此的更多信息。 https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html