如何从Elasticsearch获取数据?

Pooja

这是Elasticsearch查询,用于获取owner1First为Donald和owner2Last为Brown的文档。但是此查询将所有文档作为结果提供,并且不进行过滤。

curl -XGET "http://localhost:9200/test2/extract/_search" -d"
{"query" :
 {"filtered" :
  { "filter" : 
   {"bool" :
    {"should" :
     [{ "term" :
       {"owner1First" :"Donald"}},
       { "term" :{"owner1Last" : "Brown"}} 
     ]
       }
      }
     }
    }
   }"

您需要改为一个bool/must

curl -XGET 'http://localhost:9200/test2/extract/_search' -d '{
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must": [        <---- use must here !
            {
              "term": {
                "owner1First": "donald"
              }
            },
            {
              "term": {
                "owner1Last": "brown"
              }
            }
          ]
        }
      }
    }
  }
}'

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章