gpt4 book ai didi

elasticsearch - 在 ElasticSearch 中以百分比调整模糊级别

转载 作者:行者123 更新时间:2023-12-02 22:26:50 25 4
gpt4 key购买 nike

我正在一个项目中使用我的过滤器,每当用户点击它时,他都会得到与他/她的文本匹配的所有评论(单词)
我自己的文档如下:

{
"_index": "halohas",
"_type": "haloha",
"_id": "5f301d2783cfcb1f016db3e2",
"_score": 28.848064,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "2-year old sleeping peacefully 😴 ",
"mood": 2
}
}
这些是我得到的结果:-
{
"took": 31,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 36,
"relation": "eq"
},
"max_score": 28.848064,
"hits": [
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f301d2783cfcb1f016db3e2",
"_score": 28.848064,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "2-year old sleeping peacefully 😴 ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f2ff43673a23c19f93f3f83",
"_score": 8.229242,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "when wake find 5 year old slipped bed ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f2ffc6f632e0a21335f34d2",
"_score": 5.6028643,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "view grandmother’s old house. ❤️ ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f30b258a7c85000ec438473",
"_score": 5.6028643,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "streets old Quebec City. 😍 ",
"mood": 5
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f3001608007db1d155f9222",
"_score": 5.5635624,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "dog laying floor sleeping peacefully it’s view little world s bd grateful it. ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f30d0466b4cf850f909f342",
"_score": 5.0614862,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "daughters sleeping beds 😻 ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f30077d93afb8280769fae2",
"_score": 5.056673,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "beach sunny, cold day. ",
"mood": 0
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f30c2d56b7f9d4117391f03",
"_score": 4.938582,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "view children sleeping. ",
"mood": 1
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f30dbf67fc599245178ed02",
"_score": 4.931981,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "sleeping puppies kittens. ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f300fc438bbba64136cd442",
"_score": 4.6257343,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "back deck looking lake. Never gets old. ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f3003454d2bcf78c37246e2",
"_score": 4.43775,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "out window, through 2 columns HDB buildings. ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f30547f2242bf327e522f62",
"_score": 4.2923875,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "seeing daughter happy! ",
"mood": 0
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f3008be88705c67ba1b2be2",
"_score": 4.133784,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "peaceful landscapes mountains, cool, urban cityscape ",
"mood": 0
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f3037d7c7521c22011e5f52",
"_score": 3.879126,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "walking Disney World Park every 2-3 years when go. big thunder lightning rain storm. ",
"mood": 0
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f2ff9795d4acf75f1130c62",
"_score": 3.732638,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "mountain overlook near home. ",
"mood": 1
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f30b70b385cb141027b0392",
"_score": 3.6982667,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "seeing family together ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f300b0c5947d73b2f1f2042",
"_score": 3.4434087,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "Something peaceful blue sky ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f3045a0b64c7079e870eb83",
"_score": 3.2923517,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "nature . really enjoy seeing different kinds beauty nature provides ",
"mood": 0
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f30ad854091a30e3748fdc3",
"_score": 3.2879872,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "seeing family happy ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f2ffa503f71da190151b6e3",
"_score": 3.2355409,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "standing top Primrose Hill seeing over London😍 ",
"mood": 0
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f309d55495425347e669c72",
"_score": 3.1025603,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "seeing joy faces ones love. ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f306a8f1e484142ff160182",
"_score": 2.9667428,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "beach, anything calming makes feel peaceful inspired ",
"mood": 1
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f3047beaf93087d444c9522",
"_score": 2.8672628,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "deep night sky, ocean waves, desert canyons... I've got year big tree outside Brooklyn window birdwatching least! ",
"mood": 5
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f2ff9b8d29c5168616b02a2",
"_score": 2.7855852,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "waking seeing fiancé's sleepy face. ♡ ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f302f57c182084e3c52af43",
"_score": 2.7658296,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "very thankful life .i peaceful soul .i come here spreading love happiness.i want anything people. ",
"mood": 0
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f2ff3c74e317d52562f5fe2",
"_score": 2.3884435,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "looking over balcony seeing nice blue ocean ",
"mood": 4
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f2ff4b38c9d562a32727532",
"_score": 2.2355409,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "seeing smile back me💯🔥🔥🔥 ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f303089c86120678e40dff2",
"_score": 2.2118597,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "looking out over city night seeing all lights cars buildings ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f300cc1ac527721047cc773",
"_score": 2.2118597,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "light rain pouring down mixed thunderstorms seeing view window <3 ",
"mood": 6
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f306a2e55389a57b969edb2",
"_score": 1.9858739,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "nice sunset. usually walk park near house whenever bored, sit grass front beautiful pond. Suchaniceview ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f310e5fe992803f2556f732",
"_score": 1.8445822,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "favourite view view sea when it's sunset. feels calm peaceful eyes see such beautiful scene ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f3013471241a213832e3392",
"_score": 1.8249211,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "view mountains, forest, apple orchard mom's front porch upstate NY. Sometimes there bears, turkey, deer. peaceful! ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f302325a082044a4b271642",
"_score": 1.7797891,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "site seeing nature....*I wrote wanted read other beautiful halohas 😁♥️* ",
"mood": 3
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f307297bec4a071590739b2",
"_score": 1.6909387,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "Vacation:the ocean, now-destroyed deck Hurricane Dorian, Hopetown, Elbow Cay, Bahamas. Home view woods - serene peaceful. ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f30a16bfd669a03a227f6f3",
"_score": 1.5437499,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "view airplane when really high view seeing all things see everyday different view ✈️✈ ",
"mood": 2
}
},
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f30485d9dcac5290736fff2",
"_score": 1.1237957,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "bedroom windows (my bedroom attic) sunset clear night sky. Also view bathroom while shower morning 🌌 ",
"mood": 2
}
}
]
}
}
当我通过查询获取结果时,它会给我上面给出的所有 3 个结果。
我的查询如下:-
{
"query": {
"bool": {
"filter": [
{
"match": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a"
}
}
],
"must": [
{
"match": {
"text": {
"query": "passing smile each other ",
"fuzziness": "auto"
}
}
}
],
"should": [
{
"term": {
"mood": {
"value": 0
}
}
}
]
}
}
}
在结果中,如果您看到第 12 号文件是
{
"_index": "halohas",
"_type": "haloha",
"_id": "5f30547f2242bf327e522f62",
"_score": 4.2923875,
"_source": {
"haloha_id": "5f2f33c2c6f0fc27e725ee8a",
"text": "seeing daughter happy! ",
"mood": 0
}
}
我猜这里有 3 个正在匹配的字母“ing”,即在我的文档中,单词正在 sleep ,而在这个文档中,单词正在看到基于某些字母匹配的匹配这是我不想要的,因为这两个单词差别太大.
我想在模糊匹配单词上设置某种百分比,即我想设置模糊级别。
除非 80% 的字母匹配,否则我不希望任何文档返回。我怎样才能做到这一点?

最佳答案

Fuzziness
被解释为 Levenshtein 编辑距离 — 需要对一个字符串进行的一个字符更改的数量,以使其与另一个字符串相同。
所以“ sleep ”将与“看到”匹配,因为它们只有一个字符的差异
不支持高于 2 编辑距离的模糊性。因此,模糊性的值只能是 1 和 2,因此允许百分比是没有意义的。
检查此评论 issue

In all cases the behaviour of fuzziness can be reduced to twointegers (as fuzziness above 2 isn't supported anyway): the thresholdat which it becomes 1, and at which it becomes 2. Percentage fuzzinessused to be supported but was removed, presumably because it suggestedthat there was more flexibility when really it was just being turnedinto two thresholds.

Are you suggesting that it should be customisable at the query level,rather than in configuration? If so, some thought would probably needto be put into the syntax, as there could be confusion betweensettings that define the fuzziness and those that define the lengththresholds for fuzziness, which are both integers.

关于elasticsearch - 在 ElasticSearch 中以百分比调整模糊级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63336654/

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