ElasticSearch返回所有文档 [英] ElasticSearch returning all documents

查看:225
本文介绍了ElasticSearch返回所有文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我发送到ElasticSearch的查询:

Here is the query I am sending to ElasticSearch:

http://localhost:9200/user-index/user/_search/?queryb%5Bname%5D=Richard

返回的JSON是这样的:

The returned JSON is this:

{
  "hits": [
    {
      "_index": "user-index",
      "_type": "user",
      "_id": "WgrvE-DzQJminNreBIsRNA",
      "_score": 1.0,
      "_source": {
        "name": "Richard",
        "db_id": "7"
      }
    },
    {
      "_index": "user-index",
      "_type": "user",
      "_id": "GwMOuYbUR8y48RrG4HgXdg",
      "_score": 1.0,
      "_source": {
        "name": "John",
        "db_id": "8"
      }
    },
    {
      "_index": "user-index",
      "_type": "user",
      "_id": "C-bgK3pNTNiX9Cz0x8EftA",
      "_score": 1.0,
      "_source": {
        "name": "Harold",
        "db_id": "2"
      }
    }
  ]
}

只有其中一个实际匹配。为什么要将它们全部发回?

Only one of those actually matches. Why is it sending them all back?

推荐答案

Elasticsearch会在index user-index中返回类型为user的所有记录,因为它不能找到搜索查询。搜索查询应在参数q中指定为查询字符串请求机构

Elasticsearch returns all records with the type user in the index user-index because it cannot find the search query. The search query should be specified as a query string in the parameter "q" or as a request body.

尝试 http:// localhost:9200 / user-index / user / _search?q = name%3ARichard

这篇关于ElasticSearch返回所有文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆