0

这是我发送给 ElasticSearch 的查询:

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

返回的 JSON 是这样的:

{
  "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"
      }
    }
  ]
}

只有其中一个真正匹配。为什么要把他们都送回去?

4

1 回答 1

2

Elasticsearch 在索引 user-index 中返回所有类型为 user 的记录,因为它找不到搜索查询。搜索查询应指定为参数“q”中的查询字符串或请求正文

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

于 2012-06-03T22:47:35.440 回答