Elasticsearch Spring数据和模糊搜索

时间:2017-04-23 07:57:26

标签: elasticsearch spring-boot fuzzy-search spring-data-elasticsearch

我的Elasticsearch索引有以下数据:

    {
      "_index" : "neo4j-index-node",
      "_type" : "Decision",
      "_id" : "335",
      "_score" : 1.0,
      "_source" : {
        "avgVotesWeight" : 0.0,
        "nameSlug" : "avast-internet-security",
        "lowerName" : "avast internet security",
        "description" : "Protect yourself against identity theft, phishing emails, infected websites, and more. Avast Internet Security comes with SafeZone, the world's most secure browser. Avoid annoying ads with Ad Blocker, use the Video Downloader to watch your favorite videos offline, and bank or shop in Bank Mode so no spy or hacker can track you. All the power, speed, and accessibility of our free antivirus but with even more kick to really give the boot to every threat you encounter online. It also features an enhanced Game Mode to maximize your gaming experience. ",
        "totalDislikes" : 0,
        "totalChildDecisions" : 0,
        "totalCriteria" : 0,
        "multiVotesAllowed" : false,
        "totalCharacteristics" : 0,
        "totalFlags" : 0,
        "totalComments" : 0,
        "likeSum" : 0.0,
        "totalVotes" : 0,
        "name" : "Avast Internet Security",
        "totalLikes" : 0,
        "createDate" : "2017-04-23T07:30:17.800Z"
      }
    }

这是我在ES索引中的测试名称的完整列表:

Avast Premier
AVG Antivirus
AVG Internet Security
Avira Antivirus FREE (formerly AntiVir)
F-Secure Antivirus
Windows Defender
NANO Antivirus
Panda Antivirus Free
Norton AntiVirus
Spyware Doctor with AntiVirus
Antivirus software for Windows
Bitdefender Antivirus Free
Bitdefender Antivirus Plus
Bitdefender Internet Security
ZoneAlarm PRO Antivirus + Firewall
AVG Antivirus FREE
ESET Smart Security
Sophos EndUser Protection
SecureAnywhere Internet Security Plus and Complete
Comodo Internet Security
360 Total Security
TrustPort Antivirus
F-PROT Antivirus
McAfee Antivirus
Avast Internet Security
Avira Internet Security
ZoneAlarm Extreme Security
ClamWin
ESET NOD32 Antivirus
FortiClient
Kaspersky Anti-Virus
Panda Antivirus Pro
Quick Heal Total Security
Titanium Internet Security
SecureAnywhere AntiVirus
Avast Pro Antivirus
Dr.Web Anti-virus
F-Secure Internet Security
G DATA AntiVirus
G DATA InternetSecurity
iolo System Shield Antivirus & Antispyware
KingSoft Antivirus
McAfee Internet Security
Norton Internet Security
TrustPort Internet Security
Vba32 AntiVirus
Zemana Antilogger and Antimalware
Outpost AntiVirus Pro
Outpost Security Suite
AhnLab V3 Internet Security
Avast Free Antivirus
Comodo Antivirus
Comodo Antivirus Advanced
Dr.Web Security Space
Kaspersky Internet Security
Panda Internet Security
Sophos Anti-Virus
Immunet
Titanium Antivirus Plus
TrustPort Total Protection

我希望对名称和/或描述属性实施模糊搜索。

现在,在我的Spring Data Elasticsearch中,我添加了以下自定义存储库方法:

@Override
public List<ESDecision> findAllDecisionsFuzzyBySearchTerm(String searchTerm) {
    Criteria c = new Criteria("name").fuzzy(searchTerm).or(new Criteria("description").fuzzy(searchTerm));
    return elasticsearchTemplate.queryForList(new CriteriaQuery(c), ESDecision.class);
}

例如,当searchTerm = "Antivir"时,我唯一的结果是Avira Antivirus FREE (formerly AntiVir)而且那就是它......

为什么结果中不包含例如AntivirusAntiVirus字的所有其他名称?

此外,当我搜索多项查询时,例如Avast Pro Antivirus,根本找不到任何内容。

我做错了什么以及如何重写我的findAllDecisionsFuzzyBySearchTerm方法以进行真正的模糊搜索?

0 个答案:

没有答案