Ram*_*ddy 5 search relevance elasticsearch elasticsearch-query
需要对候选人的技能和多年经验应用搜索条件
以下是条件
以下是有关应用的映射和查询的详细信息,这些信息不起作用
// 我的索引映射
{
"skills": {
"type": "nested",
"dynamic": "true",
"properties": {
"id": {
"type": "long"
},
"isHighlight": {
"type": "boolean"
},
"skill": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 32766,
"normalizer": "lowerasciinormalizer"
}
}
},
"yearsOfExp": {
"type": "float"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
下面是我的索引数据
{
"_index": "tenant1_candidate",
"_type": "docs",
"_id": "953",
"_score": 0.0074906712,
"_source": {
"record": {
"skills": [
{
"id": 0,
"skill": "Jr.Software Developer",
"yearsOfExp": 2,
"isHighlight": false
},
{
"id": 0,
"skill": "AJAX",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Angular Developer",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "AngularJS",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Apache Subversion",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "API",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Bachelors Degree",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Back End",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Bootstrap",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Cascading Style Sheets",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "CRUD",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "CSS3",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Design Patterns",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Excellent analytical and logical programming skills",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Front End",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Git",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "HTML",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "HTML5",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "JavaScript",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "jQuery",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Jr. UI Developer",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "JSON",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Microsoft Access",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Microsoft SQL Server",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Microsoft Visual Studio",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "MySQL",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Object Oriented Analysis/Design",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Responsive Web Design",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "REST API",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "RESTful",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Test-Driven Development",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "TypeScript",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Version Control",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "Web Services",
"yearsOfExp": 1,
"isHighlight": false
},
{
"id": 0,
"skill": "XML",
"yearsOfExp": 1,
"isHighlight": false
}
]
},
"entityType": "Candidate",
"index": "tenant1_candidate",
"dbId": "953",
"id": "953"
}
}
Run Code Online (Sandbox Code Playgroud)
下面是我的搜索查询
{
"from": "0",
"size": "30",
"track_scores": true,
"query": {
"bool": {
"must": [
{
"term": {
"entityType": "candidate"
}
},
{
"nested": {
"path": "record.skills",
"score_mode": "avg",
"query": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"match": {
"record.skills.skill.keyword": "XML"
}
},
{
"range": {
"record.skills.yearsOfExp": {
"gte": 0
}
}
}
]
}
},
{
"bool": {
"must": [
{
"match": {
"record.skills.skill.keyword": "SQL"
}
},
{
"range": {
"record.skills.yearsOfExp": {
"gte": 0
}
}
}
]
}
}
]
}
}
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
示例数据:
Candidate1 : name: x, Skills: [ { name: sk1, exp: 2 }, { name: sk2, exp: 5 }, { name: sk3, exp: 3 }]
Candidate2 : name: y, Skills: [ { name: sk1, exp: 1 }, { name: sk5, exp: 4 }, { name: sk3, exp: 1 }]
在搜索查询技能可以是强制性的或非强制性的
| 归档时间: |
|
| 查看次数: |
124 次 |
| 最近记录: |