if (StringUtils.isNotBlank(query.nameOrKey())) {
result.must(
queryFilter(
- multiMatchQuery(query.nameOrKey(), RuleDocument.FIELD_NAME, RuleDocument.FIELD_KEY)
+ multiMatchQuery(query.nameOrKey(), RuleDocument.FIELD_NAME + ".search", RuleDocument.FIELD_KEY)
.operator(Operator.AND)));
}
"type": "custom",
"tokenizer": "keyword",
"filter": "lowercase"
+ },
+ "rule_name": {
+ "type": "custom",
+ "tokenizer": "rule_name_ngram",
+ "filter": "lowercase"
+ }
+ },
+ "tokenizer": {
+ "rule_name_ngram": {
+ "type": "nGram",
+ "min_gram": 3,
+ "max_gram": 5,
+ "token_chars": [ "letter", "digit" ]
}
}
}
"type": "multi_field",
"fields": {
"name": { "type": "string", "index": "analyzed" },
- "raw": { "type": "string", "index": "analyzed", "analyzer": "sortable" }
+ "raw": { "type": "string", "index": "analyzed", "analyzer": "sortable" },
+ "search": { "type": "string", "index": "analyzed", "analyzer": "rule_name" }
}
},
"description": {
// Match on name
assertThat(profileRules.search(ProfileRuleQuery.create(1).setNameOrKey("Unused Check"), paging).rules()).hasSize(1);
+ assertThat(profileRules.search(ProfileRuleQuery.create(1).setNameOrKey("unus"), paging).rules()).hasSize(1);
// Match on repositoryKey
assertThat(profileRules.search(ProfileRuleQuery.create(1).addRepositoryKeys("findbugs"), paging).rules()).hasSize(1);