javascript - 显示来自不同弹性搜索索引的建议?
问题描述
假设我在 elasticsearch 中有两个索引。第一个names
包含五个值Ram, Shyam, Hari, Dipu, Kishan
,第二个profession
包含五个值,例如teacher, driver, doctor, bank manager, salesman
. 当有人打字时Ra
,我想显示类似的建议
Ram is teacher
Ram is driver
Ram is doctor
Ram is bank manager
Ram is salesman
同样,当有人打字时Har
,我想显示
Hari is teacher
Hari is driver
Hari is doctor
Hari is bank manager
Hari is salesman
我不想存储所有可能的组合。还假设用户正在寻找Ram is a doctor at Raman Hospital since 2002.
这里Ram, doctor, Raman Hospital, 2002
属于不同的不同索引。当用户键入时Ram
,我想将建议显示为Ram is a teacher at Basic Boys School Since 2002
, Ram is salesman at HUL since 2006
。如果还有一个有名字的人,Raman
那么Raman is driver at Ola since 2012
也应该显示为建议。对于此类搜索,是否有任何好的方法可用,或者我必须为此努力?
映射:
PUT name
{
"mappings": {
"_doc" : {
"properties" : {
"suggest" : {
"type" : "completion",
"contexts": [
{
"name": "userid",
"type": "category"
}
]
}
}
}
}
}
索引:
POST name/_doc/
{
"suggest": {
"input": ["BHANU PRAKASH"],
"contexts": {
"userid": ["99569858","99156661","90273758","6598242461","65910563"]
}
}
}
解决方案
推荐阅读
- r - R中的TSLM函数
- android - 当在键盘上按下特定字符时,我可以切换到另一个 EditText 吗?
- javascript - TypeError:无法读取 react^16.13.1 react-router-dom^5.2.0 中未定义的属性“位置”
- string - 在 oracle 中用换行符在一列中显示两个字符串列的结果
- javascript - 状态更改未重新呈现组件概念问题
- c# - 为什么我在 Global.asax.cs 中的 Application_BeginRequest 没有被自托管的 WCF 服务调用
- mysql - 403 与服务器的连接已丢失 Phpmyadmin
- amazon-web-services - 404 Not Found nginx/1.19.0 istio spring boot
- vue.js - VueJS计算过滤器功能不起作用
- reactjs - 当我尝试做 create-react-app 给出不同的错误