简体   繁体   English

ElasticSearch不返回所有结果

[英]ElasticSearch Not returning all results

I have this set of Data 我有这组数据

{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 16,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "tenant1",
      "_type" : "consultation",
      "_id" : "100038",
      "_score" : 1.0, "_source" : {"id":"100038","patientPin":"2012010000000020","prescriptions":[],"diagnosis":["Amoebiasis"],"patientFirstName":"Scooby","patientLastName":"Doo","documentDate":"06/13/2014"}
    }, {
      "_index" : "tenant1",
      "_type" : "consultation",
      "_id" : "100007",
      "_score" : 1.0, "_source" : {"id":"100007","patientPin":"2012010000000016","prescriptions":["METHISOPRINOL ISOPRINOSINE"],"diagnosis":["Alcohol Intoxication"],"patientFirstName":"Johnny","patientLastName":"Bravo","documentDate":"06/10/2014"}
    }, {
      "_index" : "tenant1",
      "_type" : "consultation",
      "_id" : "100015",
      "_score" : 1.0, "_source" : {"id":"100015","patientPin":"2012010000000010","prescriptions":[],"diagnosis":["Amoebiasis"],"patientFirstName":"Tweety","patientLastName":"Bird","documentDate":"06/10/2014"}
    }, {
      "_index" : "tenant1",
      "_type" : "consultation",
      "_id" : "100027",
      "_score" : 1.0, "_source" : {"id":"100027","patientPin":"2012010000000014","prescriptions":[],"diagnosis":["Food Poisoning"],"patientFirstName":"Marvin","patientLastName":"Martian","documentDate":"06/11/2014"}
    }, {
      "_index" : "tenant1",
      "_type" : "consultation",
      "_id" : "100046",
      "_score" : 1.0, "_source" : {"id":"100046","patientPin":"2012010000000027","prescriptions":[],"diagnosis":["Amoebiasis"],"patientFirstName":"Yabba","patientLastName":"Doo","documentDate":"06/13/2014"}
    }, {
      "_index" : "tenant1",
      "_type" : "consultation",
      "_id" : "100058",
      "_score" : 1.0, "_source" : {"id":"100058","patientPin":"2012010000000003","prescriptions":[],"diagnosis":["Amoebiasis"],"patientFirstName":"Elmer","patientLastName":"Fudd","documentDate":"06/13/2014"}
    }, {
      "_index" : "tenant1",
      "_type" : "consultation",
      "_id" : "100042",
      "_score" : 1.0, "_source" : {"id":"100042","patientPin":"2012010000000021","prescriptions":[],"diagnosis":["Amoebiasis"],"patientFirstName":"Scrappy","patientLastName":"Doo","documentDate":"06/13/2014"}
    }, {
      "_index" : "tenant1",
      "_type" : "consultation",
      "_id" : "100054",
      "_score" : 1.0, "_source" : {"id":"100054","patientPin":"2012010000000026","prescriptions":[],"diagnosis":["Amoebiasis"],"patientFirstName":"Scooby","patientLastName":"Dum","documentDate":"06/13/2014"}
    }, {
      "_index" : "tenant1",
      "_type" : "consultation",
      "_id" : "100066",
      "_score" : 1.0, "_source" : {"id":"100066","patientPin":"2012010000000015","prescriptions":[],"diagnosis":["Amoebiasis"],"patientFirstName":"Hippety","patientLastName":"Hopper","documentDate":"06/13/2014"}
    }, {
      "_index" : "tenant1",
      "_type" : "consultation",
      "_id" : "100050",
      "_score" : 1.0, "_source" : {"id":"100050","patientPin":"2012010000000002","prescriptions":[],"diagnosis":["Amoebiasis"],"patientFirstName":"Daffy","patientLastName":"Duck","documentDate":"06/13/2014"}
    } ]
  }
}

However, when I am querying through Google Chromes' Rest Console with this query 但是,当我使用此查询通过Google Chrome浏览器的Rest Console查询时

{
    "query" : {
        "match" : {
            "patientFirstName" : "Scooby"
        }
    }
}

It returns all the result here's the URL I am using to search 它返回所有结果,这是我正在搜索的URL

http://localhost:9200/tenant1/consultation/_search

I also even did 我什至也做过

http://localhost:9200/tenant1/consultation/_search?patientLastName:Doo

and it still return all results. 并且仍然返回所有结果。 It supposed to return only one result 它应该只返回一个结果

将查询更改为此。(添加_search?q =)

http://localhost:9200/tenant1/consultation/_search?q=patientLastName:Doo

Try a bool query, this will ensure that it has the following to return it as a result - 尝试进行布尔查询,这将确保它具有以下内容可作为返回结果-

{
    "query": {
        "bool": {
            "must": {
                "term": {
                    "patientFirstName": "Scooby"
                }
            }
        }
    }
}

More information here. 更多信息在这里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM