gpt4 book ai didi

curl - Elasticsearch从命令行使用cURL返回搜索结果中的虚假匹配

转载 作者:行者123 更新时间:2023-12-03 01:58:37 28 4
gpt4 key购买 nike

我在让Elasticsearch 1.7.x玩球时遇到了很多麻烦-我一直在尝试通过已使用它的搜索来实现错误修复和一些额外的评分功能,但经常包含不相关的结果。

因此,我决定使用以下查询返回绝对基础:

curl -XGET http://localhost:9200/merchantv2/_search '
{
"query": {
"match": {
"businessName": "test"
}
}
}'

目前,我的索引中只有两个文档。一种是 businessName设置为“Test Merchant”,我希望上面的查询可以匹配,另一种是将businessName设置为“”,我希望它不匹配。

但是,运行该精确查询的结果如下:
{  
"took":1,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"failed":0
},
"hits":{
"total":2,
"max_score":1.0,
"hits":[
{
"_index":"merchantv2",
"_type":"searchablemerchant",
"_id":"00000000-0000-0000-0000-000000000000",
"_score":1.0,
"_source":{
"merchantGuid":"00000000-0000-0000-0000-000000000000",
"v1MerchantId":0,
"locatorId":"0",
"address":{
"addressGuid":"00000000-0000-0000-0000-000000000000",
"postCodeDetails":{
"postCodeKey":0,
"postalDistrict":{
"postalDistrictKey":0,
"postalDistrict":""
},
"postalLocation":"0",
"latitude":0.0,
"longitude":0.0,
"townName":"None",
"countyKey":0,
"countryKey":0,
"postCode":{
"postCodeKey":0,
"postCode":" 0"
}
},
"county":{
"countyKey":0,
"countyName":"",
"countryKey":0,
"recStatus":3,
"countryKeyValue":0
},
"countryKey":0,
"addressTypeKey":0,
"updateDate":"0001-01-01T00:00:00+00:00",
"createdDate":"2016-01-07T19:46:28.4463+00:00"
},
"searchableAddress":" 0",
"searchablePhone":"",
"searchableFax":"",
"businessName":"",
"contacts":[

],
"opportunities":[
{
"opportunityGuid":"00000000-0000-0000-0000-000000000000",
"merchantGuid":"00000000-0000-0000-0000-000000000000",
"location":{
"locationGuid":"00000000-0000-0000-0000-000000000000",
"tradingAddress":{
"verified":false,
"addressGuid":"00000000-0000-0000-0000-000000000000",
"postCodeDetails":{
"postCodeKey":0,
"postalDistrict":{
"postalDistrictKey":0,
"postalDistrict":""
},
"postalLocation":"0",
"latitude":0.0,
"longitude":0.0,
"townName":"None",
"countyKey":0,
"countryKey":0,
"postCode":{
"postCodeKey":0,
"postCode":" 0"
}
},
"county":{
"countyKey":0,
"countyName":"",
"countryKey":0,
"recStatus":3,
"countryKeyValue":0
},
"countryKey":0,
"addressTypeKey":0,
"updateDate":"0001-01-01T00:00:00+00:00",
"createdDate":"2016-01-07T19:46:28.4463+00:00"
}
},
"opportunityLocatorId":"000000"
}
]
}
},
{
"_index":"merchantv2",
"_type":"searchablemerchant",
"_id":"5f55fe61-ca65-e411-93f3-0cc47a07ef4a",
"_score":1.0,
"_source":{
"merchantGuid":"5f55fe61-ca65-e411-93f3-0cc47a07ef4a",
"locatorId":"PM227Z02",
"address":{
"addressGuid":"5c55fe61-ca65-e411-93f3-0cc47a07ef4a",
"houseNumber":"242",
"streetName":"Acklam Road",
"houseName":"",
"flatAptSuite":"",
"townName":"London",
"postCodeDetails":{
"postCodeKey":1,
"postalDistrict":{
"postalDistrictKey":2782,
"postalDistrict":"W10"
},
"postalLocation":"5JJ",
"latitude":51.52094651,
"longitude":-0.20149990,
"townName":"London",
"countyKey":0,
"countryKey":224,
"postCode":{
"postCodeKey":1,
"postCode":"W10 5JJ"
}
},
"county":{
"countyKey":626,
"countyName":"Kensington And Chelsea",
"countryKey":224,
"recStatus":1,
"countryKeyValue":224
},
"countryKey":224,
"addressTypeKey":0,
"updateDate":"0001-01-01T00:00:00+00:00",
"createdDate":"2016-01-07T19:46:28.4653+00:00"
},
"searchableAddress":"242 Acklam Road, London, Kensington And Chelsea, W10 5JJ",
"searchablePhone":"+44 2031954484",
"searchableFax":"",
"businessName":"Test Merchant",
"contacts":[

],
"opportunities":[

]
}
}
]
}
}

请注意,有两个匹配项,其中一个是带有空 businessName的文档。

WT ...?

有人可以向我解释为什么会这样吗?

(我已使用 https://www.elastic.co/guide/en/elasticsearch/guide/1.x/query-dsl-intro.html的“查询子句的结构”下的第一个 match示例查询作为模板。)

编辑:完全我不好(我很高兴地说)

与Elasticsearch无关。我到处都在复制和粘贴 curl命令,然后对它进行了过度编辑。缺少-d标志意味着查询文档未提交给Elasticsearch,实际上将我的命令变成了:
curl -XGET http://localhost:9200/merchantv2/_search

当然,这将返回索引中的所有文档。 #facepalm

最佳答案

当发送带有curl的搜索有效负载时,您需要使用-d命令行开关,否则您将无限制地命中_search端点:

                                               this is missing
|
V
curl -XGET http://localhost:9200/merchantv2/_search -d '
{
"query": {
"match": {
"businessName": "test"
}
}
}'

关于curl - Elasticsearch从命令行使用cURL返回搜索结果中的虚假匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34721411/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com