【发布时间】:2019-02-27 20:05:39
【问题描述】:
我们一直在试验我们的 ElasticSearch 实例来构建一个查询,该查询将查找包含非结构化格式文本的文档。这份特殊的文件给我们带来了很大的困难。
这是文档中名为“Text”的字段的内容。
PUBLIC NOTICE – September 2013 NORTH DAKOTA BOARD OF NURSING 919 S 7th Street, Suite 504, Bismarck, ND 58504-5881; (701) 328-9777; Web Site www.ndbon.org PLEASE SHARE THIS INFORMATION WITH YOUR NURSING STAFF The North Dakota Board of Nursing took the following action during the September 19, 2013 meeting: Disciplinary/Board Action Action Name Registration # City/State Time frame Penalty fee Reprimand *Anderson, Merry 106815UAP Minot, ND N/A $200 * Practice without *Buboltz, Ann RN Applicant Redwood Falls, MN N/A $200 License/ Dockter, Amanda L13872 Kensal, ND N/A $900 Registration Jaffe, James R39137 Elkhart, IN N/A $600 *Miller, Cassandra RN Applicant Wahpeton, ND N/A $1,000 *Parker-Sundquist, Charla LPN Applicant Grand Forks, ND N/A $200 Extension of Cofer, Kelly R32728 & L11293 Grand Forks, ND 3 years $1,500 Previous Wattendorf.
请注意文本块末尾的短语“Parker-Sundquist,Charla”。
当搜索名称 Charla Parker-Sundquist 的任何变体时,我们需要在结果集中返回此文档。现在,如果我们搜索 Charla Parker-Sunquist 或搜索 Parker-Sundquist, Charla,我们可以返回文档。但是,我们尝试在 Charla R Parker-Sundquist(包括中间名首字母)上进行搜索,但没有返回该文档。
我们需要调整这个查询(或构建一个额外的),以允许轻微的变化,例如添加中间首字母,并且仍然返回该文档,但是,没有 表示应返回包含至少一个搜索词的所有文档的查询。我相信我们需要对这个查询做的是说我们想要返回至少有两个搜索词存在并且两个词彼此接近的任何结果。
这是我们现在的查询。这样,当搜索上述两个变体时,将返回相关文档。但是,只要我们在查询中引入中间名首字母,就不会返回文档。请帮助我了解我们如何调整此查询,而不必说这 3 个单词中的 ANY 可以在文档中以供返回。
{
"size": 150,
"query": {
"function_score": {
"query": {
"bool": {
"must": {
"bool": {
"should": [
{
"match_phrase": {
"text": {
"query": "charla r parker-sundquist",
"slop": 3
}
}
}
]
}
}
}
}
}
}
}
编辑:根据一些研究,我们也尝试过这个查询,但是这个查询根本没有带回任何结果,所以我不确定这个查询的语法是否有问题.
{
"size": 150,
"query": {
"function_score": {
"query": {
"bool": {
"must": {
"bool": {
"should": [
{
"span_near": {
"clauses": [
{
"span_multi": {
"match": {
"fuzzy": {
"text": {
"value": "charla",
"fuzziness": 2
}
}
}
}
},
{
"span_multi": {
"match": {
"fuzzy": {
"text": {
"value": "parker-sundquist",
"fuzziness": 2
}
}
}
}
}
],
"in_order": false,
"slop": 2
}
}
]
}
}
}
}
}
}
}
【问题讨论】:
标签: elasticsearch